﻿using System;
using System.Collections.Generic;
using System.Text;

namespace VietKinsNutrition.Data
{
    public static class QueryString
    {
        public static string TBLDM_CHIBO_FINDNAMESAMEPRC = "select * from TblDm_Chibo where Tenchibo = ? ";
        public static string PRCTBLDM_CHIBO_GET = "SELECT * FROM TblDm_Chibo ORDER BY Tenchibo ";
        public static string PRCTBLDM_CHIBO_ADD = "INSERT INTO TblDm_Chibo(Tenchibo,Loai) VALUES ( ? ,?) ";
        public static string PRCTBLDM_CHIBO_DEL = "delete from TblDm_Chibo where Id = ? ";
        public static string PRCTBLDM_CHIBO_UPDATE = "UPDATE TblDm_Chibo SET Tenchibo = '@Ten',Loai='@Loai' WHERE Id =@Id";
        public static string TBLDM_CHUONGTRINHGD_DEL = "delete  from TblDm_ChuongtrinhGD where  (Id = ?) ";
        public static string TBLDM_CHUONGTRINHGD_EDITPRC = "update TblDm_ChuongtrinhGD set TenChuongtrinhGD = '@TenChuongtrinhGD' where(Id = @Id)";
        public static string TBLDM_CHUONGTRINHGD_INSERTPRC = "	insert into TblDm_ChuongtrinhGD(TenChuongtrinhGD) values(?)";
        public static string TBLDM_CHUONGTRINHGD_SELECTALL_PRC = "	select * from TblDm_ChuongtrinhGD ORDER BY TenChuongtrinhGD ";
        public static string TBLDM_CHUONGTRINHGD_FINDNAMESAMEPRC = "select * from TblDm_ChuongtrinhGD where (TenChuongtrinhGD = ? ) ";
        public static string BAOCAODUONGCHATTRONGBUAAN = "" +
            " SELECT     TblThucpham_thucan.Tenthucan, TblThucpham_thucan.Calo, TblThanhphanhoahoc.Tphh_Protid, TblThanhphanhoahoc.Tphh_Lipid,                        TblThanhphanhoahoc.Tphh_GlucId, Thucphamtheobua.Soluong, TblThucpham_thucan.Nguondongvat  "
 +
           " FROM    ( TblThucpham_thucan  INNER JOIN                        TblThanhphanhoahoc ON TblThucpham_thucan.Id = TblThanhphanhoahoc.IdThucpham_thucan) "
           +
    " INNER JOIN                        Thucphamtheobua ON TblThucpham_thucan.Id = Thucphamtheobua.Thucpham_ThucanId "
    +
 " GROUP BY TblThucpham_thucan.Tenthucan, TblThanhphanhoahoc.Tphh_Protid, TblThanhphanhoahoc.Tphh_Lipid,                         TblThanhphanhoahoc.Tphh_GlucId, Thucphamtheobua.Soluong, TblThucpham_thucan.Nguondongvat, TblThucpham_thucan.Calo,                         TblThucpham_thucan.Nguondongvat, Thucphamtheobua.BuaantrongngayId, Thucphamtheobua.Ngay,                         Thucphamtheobua.Khoilop "
 + " HAVING      (Thucphamtheobua.BuaantrongngayId = @BuatrongngayId) AND (Thucphamtheobua.Ngay = @Ngay) AND                         (Thucphamtheobua.Khoilop = @KhoilopId) ";
        public static string PRC_TBLBAOCAOEMISNHANVIEN = "SELECT Count(TblNhanvien.Id) AS Tongso, TblNhanvien.Gioitinh FROM TblNhanvien  WHERE     (Trangthai = 0)  AND  ( year(DATE()) - year( Namsinh))  > @Nammin AND  (year(DATE()) - year( Namsinh))  < @Nammax   group by  TblNhanvien.Gioitinh";
        public static string PRC_TBLBAOCAOEMISNHANVIENDOTUOIDANTOC = "	SELECT     COUNT(TblNhanvien.Id) AS Tongso, TblNhanvien.Gioitinh"
 + " FROM         TblNhanvien INNER JOIN "
 + "                       TblDm_Dantoc ON TblNhanvien.DantocId = TblDm_Dantoc.Id "
 + " WHERE     (TblNhanvien.Trangthai = 0) AND (DATEDIFF(yyyy, TblNhanvien.Namsinh, GETDATE()) > @Nammin) AND (DATEDIFF(yyyy,  "
 + "                       TblNhanvien.Namsinh, GETDATE()) < @Nammax) AND (NOT (TblDm_Dantoc.Tendantoc LIKE N'%' + @Tendantoc + N'%')) "
 + " GROUP BY TblNhanvien.Gioitinh ";
        public static string PRC_TBLBAOCAOEMISTRE = "" +
           " SELECT TblDm_Phanloailop.Tenloailop, TblLop.Tenlop, TblTre.Gioitinh, Count(TblTre.Id) AS Tongso "
           +
 " FROM TblTre INNER JOIN ((TblLop INNER JOIN TblDm_Phanloailop ON TblLop.PhanloailopId = TblDm_Phanloailop.Id) INNER JOIN TblNamtrehoc ON TblLop.Id = TblNamtrehoc.LophocId) ON TblTre.Id = TblNamtrehoc.TreId "
 + " WHERE (TblTre.Tinhtrang=0 and TblLop.NamhocId =@NamhocId and "
 + " month(Date() ) - Month(TblTre.Ngaysinh)  > @Thangmin " +
" and month(Date() ) - Month(TblTre.Ngaysinh)  <= @Thangmax ) "
+ "GROUP BY TblDm_Phanloailop.Tenloailop, TblLop.Tenlop, TblTre.Gioitinh";

        public static string PRC_TBLBAOCAOEMISTRE0 =
            "" +
           " SELECT TblDm_Phanloailop.Tenloailop, TblLop.Tenlop, TblTre.Gioitinh, Count(TblTre.Id) AS Tongso "
           +
 " FROM TblTre INNER JOIN ((TblLop INNER JOIN TblDm_Phanloailop ON TblLop.PhanloailopId = TblDm_Phanloailop.Id) INNER JOIN TblNamtrehoc ON TblLop.Id = TblNamtrehoc.LophocId) ON TblTre.Id = TblNamtrehoc.TreId "
 + " WHERE ( (TblTre.Tinhtrang=0) and (TblLop.NamhocId =@NamhocId) and "
 + " (month(Date() ) - Month(TblTre.Ngaysinh)  >= @Thangmin) " +
" and (month(Date() ) - Month(TblTre.Ngaysinh)  <= @Thangmax) ) "
+ "GROUP BY TblDm_Phanloailop.Tenloailop, TblLop.Tenlop, TblTre.Gioitinh";

        public static string PRC_TBLBAOCAOEMISTREDOTUOIDANTOC = "SELECT     TblDm_Phanloailop.Tenloailop, TblLop.Tenlop, TblTre.Gioitinh, COUNT(TblTre.Id) AS Tongso"
 + " FROM         TblTre INNER JOIN "
 + "                       TblNamtrehoc ON TblTre.Id = TblNamtrehoc.TreId INNER JOIN "
 + "                       TblLop ON TblNamtrehoc.LophocId = TblLop.Id INNER JOIN "
 + "                       TblDm_Phanloailop ON TblLop.PhanloailopId = TblDm_Phanloailop.Id  "
 + " WHERE     (TblTre.Tinhtrang = 0) AND (DATEDIFF(mm, TblTre.Ngaysinh, GETDATE()) <= @Thangmax) AND (DATEDIFF(mm, TblTre.Ngaysinh, GETDATE())  "
 + "                       > @Thangmin) --AND (NOT (TblDm_Dantoc.Tendantoc LIKE N'%' + @Tendantoc + N'%')) "
 + " GROUP BY TblDm_Phanloailop.Tenloailop, TblLop.Tenlop, TblTre.Gioitinh "
;
        public static string PRC_TBLNGUYENLIEUTONKHO = "SELECT      SUM(Soluong) AS Soluong, Thucpham_ThucanId"
 + " FROM         (SELECT     Dongia, Soluong, Thucpham_ThucanId "
 + "                        FROM          View_Nhaphanghoa "
 + "                        UNION all "
 + "                        SELECT     Dongia, Soluong, Thucpham_ThucanId "
 + "                        FROM         View_Xuathanghoa) AS TblNhapxuathanghoa "
 + " GROUP BY Thucpham_ThucanId "
 + " HAVING      (SUM(Soluong) <> 0) ";
        public static string PRC_TBLNGUYENLIEUTONKHOVAGIA = "SELECT     SUM(Soluong) AS Soluong, Thucpham_ThucanId, Dongia"
 + " FROM         (SELECT     Dongia, Soluong, Thucpham_ThucanId "
 + "                        FROM          View_Nhaphanghoa "
 + "                        UNION all "
 + "                        SELECT     Dongia, Soluong, Thucpham_ThucanId "
 + "                        FROM         View_Xuathanghoa) AS TblNhapxuathanghoa "
 + " where(Thucpham_ThucanId =?) "
 + " GROUP BY Thucpham_ThucanId, Dongia "
 + " HAVING      (SUM(Soluong) <> 0) ";
        public static string PRC_TBLTHAMSODAUVAO_INSERT = "	"
 + " 	insert into TblThamsodauvao(Baoanchitiet,Chitietdiemtruong) values(@Baoanchitiet,@Chitietdiemtruong) ";
        public static string PRCTBL_UPDATE = "	 		 UPDATE    TblNhapxuathanghoa"
 + " 	 		 SET              Dongia = ? "
 + " 	 		 WHERE     (Thucpham_ThucanId = @ID) AND (HoadonnhapxuatId = @SHD) ";
        public static string PRCTBL_UPDATETHUCPHAM = "UPDATE TblNhapxuathanghoa SET Soluongcon = ? WHERE Thucpham_ThucanId = ? and HoadonnhapxuatId = @SHD";
        public static string PRCTBLDM_CAPNHATTHUCPHAM_FINDSAMENAME = "SELECT Id, NhomthucanId, Tenthucan, Tylequydoi, Tylethai, DonvitinhId, gam, Calo, Nguyenlieu, Nguondongvat, Nam FROM TblThucpham_thucan WHERE Tenthucan = ? ";
        public static string PRCTBLDM_CAPNHATTHUCPHAM_GET = "SELECT * FROM TblThucpham_thucan";
        public static string PRCTBLDM_CAPNHATTHUCPHAM_INSERT = "INSERT INTO TblThucpham_thucan (NhomthucanId, Tenthucan, Tylequydoi, Tylethai, DonvitinhId, Calo, Nguyenlieu, Nguondongvat, Nam) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) ";
        public static string PRCTBLDM_CAPNHATTHUCPHAM_UPDATE = "UPDATE TblThucpham_thucan SET NhomthucanId=@nhomThucAnId, Tenthucan=@tenThucAn, Tylequydoi=@tyLeQuyDoi, Tylethai=@tyLeThai, DonvitinhId=@donViTinhId, Calo=@calo, Nguyenlieu=@nguyenLieu, Nguondongvat=@nguonDongVat, Nam=@nam WHERE (Id = @id_ThucPham) ";
        public static string PRCTBLDM_CHECKUSER = " SELECT TblHoadonnhapxuat.NgayNX, TblHoadonnhapxuat.Trangthai, TblNhapxuathanghoa.Dongia"
 + " 			 FROM         TblHoadonnhapxuat INNER JOIN "
 + " 								   TblNhapxuathanghoa ON TblHoadonnhapxuat.Id = TblNhapxuathanghoa.HoadonnhapxuatId "
 + " 			 WHERE     (TblHoadonnhapxuat.Trangthai = 1) "
 + " 			 ORDER BY TblHoadonnhapxuat.NgayNX DESC ";
        public static string PRCTBLDM_CHITIETXUAT_INSERT = "	 if @Option=1"
 + " 		 INSERT INTO TblNhapxuathanghoa "
 + " 		                       (HoadonnhapxuatId, DonvitinhId, Thucpham_ThucanId, Soluong, Dongia) "
 + " 		 VALUES     (@HoadonnhapxuatId,@DonvitinhId,?,?, @Dongia) "
 + " 	if @Option=2 "
 + " 		 UPDATE    TblNhapxuathanghoa "
 + " 		 SET              Soluongcon = ? "
 + " 		 WHERE     (Id = @HoadonnhapxuatId)  "
 + " 	if @Option=3 "
 + " 		 INSERT INTO TblNhapxuathanghoa "
 + " 		                       (HoadonnhapxuatId, DonvitinhId, Thucpham_ThucanId, Soluong, Dongia) "
 + " 		 VALUES     (@HoadonnhapxuatId,@DonvitinhId,?,?,@Dongia) "
 + " 	if @Option=4 "
 + " 		 UPDATE    TblNhapxuathanghoa "
 + " 		 SET              HoadonnhapxuatId = @HoadonnhapxuatId, DonvitinhId = @DonvitinhId, Thucpham_ThucanId = ?, Soluong = ?,  "
 + " 		                       Dongia = @Dongia "
 + " 	   /*---------------------------------------------------------------------------------------------------------*/ "
 + " 	   /*         Đoạn code nè để upde lại hóa đơn xuất-----------------------------------------------------------*/ "
 + " 	if @Option=5 "
 + " 		 UPDATE    TblNhapxuathanghoa "
 + " 		 SET              Soluong = ?, Dongia = @Dongia "
 + " 		 WHERE     (HoadonnhapxuatId = @HoadonnhapxuatId) AND (Thucpham_ThucanId = ?) "
 + " 	  /*--------------------------------------------------------------------------------------------*/ "
 + " 	/*         Update lại phần nhập thêm----------------------------------------------------*/ "
 + " 	/*---------------------------------------------------*/ "
 + " 	if @Option=6 "
 + " 		 UPDATE    TblNhapxuathanghoa "
 + " 		 SET              Soluong = ?, Dongia = @Dongia "
 + " 		 WHERE     (Thucpham_ThucanId = ?) AND (HoadonnhapxuatId = @HoadonnhapxuatId) "
 + " 	/*        Id                       */ "
 + "  if @Option=7 "
 + " 		SELECT     Id, HoadonnhapxuatId, DonvitinhId, Thucpham_ThucanId, Soluong, Dongia, Soluongcon "
 + " 		FROM         TblNhapxuathanghoa "
 + " 		WHERE     (Id = @HoadonnhapxuatId) "
 + "   /*      Dua ra ID de sua                       */ "
 + "  if @Option=8 "
 + " 		SELECT     Id, DonvitinhId, Soluong, Dongia "
 + " 		FROM         TblNhapxuathanghoa "
 + " 		WHERE     (Thucpham_ThucanId = ?) AND (HoadonnhapxuatId = @HoadonnhapxuatId) "
 + "  /*------------------------------ select lastquery---------------------------------*/ "
 + " /* if @Option=8 "
 + " 		SELECT     LAST(HoadonnhapxuatId) AS Expr1 "
 + " 		FROM         TblNhapxuathanghoa*/ "
 + " 	/*	WHERE     (Thucpham_ThucanId = @TP) AND (Trangthai = 0)*/ "
 + "    /*end*/ "
 + "   	if @Option=9 "
 + " 	  UPDATE    TblNhapxuathanghoa "
 + " 		 SET              Soluongcon = Soluongcon - ? "
 + " 		 WHERE     (Id = @HoadonnhapxuatId) "

;
        public static string PRCTBLDM_GETIDLOP_GET = "	 SELECT     TblDm_Namhoc.Tennamhoc, TblLop.Id, TblLop.Tenlop"
 + " 	 FROM         TblDm_Namhoc INNER JOIN "
 + " 	                       TblLop ON TblDm_Namhoc.Id = TblLop.Id "
 + " 	 WHERE     (TblDm_Namhoc.Tennamhoc = @NamHoc) ";
        public static string PRCTBLDM_HEDAOTAO_ADD = "INSERT INTO TblDm_Hedaotao (Tenhedaotao) VALUES (@Tenhedaotao)";
        public static string PRCTBLDM_HEDAOTAO_GET = "SELECT"
 + " * "
 + " FROM "
 + " 	TblDm_Hedaotao "
 + " ORDER BY Tenhedaotao ";
        public static string PRCTBLDM_HEDAOTAO_UPDATE = "UPDATE TblDm_Hedaotao SET Tenhedaotao=@Tenhedaotao WHERE Id=@Id ";
        public static string PRCTBLDM_HOADONDICHO = "	SELECT     TblNhapxuathanghoa.Thucpham_ThucanId, TblThucpham_thucan.Tenthucan, TblDm_Donvitinh.Tendonvitinh, SUM(TblNhapxuathanghoa.Soluong) AS Soluongnhap, "
 + "                       TblNhapxuathanghoa.Dongia "
 + " FROM         TblHoadonnhapxuat INNER JOIN "
 + "                       TblNhapxuathanghoa ON TblHoadonnhapxuat.Id = TblNhapxuathanghoa.HoadonnhapxuatId INNER JOIN "
 + "                       TblThucpham_thucan ON TblNhapxuathanghoa.Thucpham_ThucanId = TblThucpham_thucan.Id INNER JOIN "
 + "                       TblDm_Donvitinh ON TblThucpham_thucan.DonvitinhId = TblDm_Donvitinh.Id "
 + " WHERE     (TblHoadonnhapxuat.Trangthai = 1) AND (TblHoadonnhapxuat.NgayNX = @NgayNX) "
 + " GROUP BY TblNhapxuathanghoa.Dongia, TblNhapxuathanghoa.Thucpham_ThucanId, TblThucpham_thucan.Tenthucan,  "
 + "                       TblDm_Donvitinh.Tendonvitinh ";
        public static string PRCTBLDM_HOADONNHAP_FINDNAME = "		SELECT     TblDm_Nhomthucpham_thucan.Tennhom, TblDm_Donvitinh.Tendonvitinh, TblDm_Nhomthucpham_thucan.Id AS IDNhom, TblDm_Donvitinh.Id AS IDDVT,"
 + " 		                       TblThucpham_thucan.Tenthucan, TblNhapxuathanghoa.Soluong, TblNhapxuathanghoa.Dongia, TblNhapxuathanghoa.HoadonnhapxuatId,  "
 + " 		                      TblNhapxuathanghoa.Dongia * TblNhapxuathanghoa.Soluong AS Tongtien, TblThucpham_thucan.Id/*, TblNhapxuathanghoa.Soluongcon */ "
 + " 		FROM         TblDm_Donvitinh INNER JOIN "
 + " 		                      TblThucpham_thucan ON TblDm_Donvitinh.Id = TblThucpham_thucan.DonvitinhId INNER JOIN "
 + " 		                      TblNhapxuathanghoa ON TblDm_Donvitinh.Id = TblNhapxuathanghoa.DonvitinhId AND  "
 + " 		                      TblThucpham_thucan.Id = TblNhapxuathanghoa.Thucpham_ThucanId INNER JOIN "
 + " 		                      TblDm_Nhomthucpham_thucan ON TblThucpham_thucan.NhomthucanId = TblDm_Nhomthucpham_thucan.Id "
 + " 		WHERE     (TblNhapxuathanghoa.HoadonnhapxuatId = @Id_Nhom) "
 + " 	/*  Đoạn này dùng để check xem số hóa đơn có  trong cơ sở dữ liệu hay chưa, nếu chưa có thì hỏi để đưa ra file exel*/ ";
        public static string PRCTBLDM_HOADONNHAPXUAT_FINDDELETE = "	 SELECT     TblThucpham_thucan.Tenthucan, TblNhapxuathanghoa.HoadonnhapxuatId, TblThucpham_thucan.Id"
 + " 	 FROM         TblThucpham_thucan INNER JOIN "
 + " 	                       TblNhapxuathanghoa ON TblThucpham_thucan.Id = TblNhapxuathanghoa.Thucpham_ThucanId "
 + " 	 WHERE     (TblNhapxuathanghoa.HoadonnhapxuatId = @IdHoadon) AND (TblThucpham_thucan.Tenthucan = @tenMonAn) ";
        public static string PRCTBLDM_HOADONXUAT_DELETE = "		 DELETE FROM TblNhapxuathanghoa"
 + " 		 WHERE     (HoadonnhapxuatId = @HoadonnhapxuatId) ";
        public static string PRCTBLDM_HOCKY_ADD = "	INSERT INTO TblDm_Hocky"
 + " 	( "
 + " 		Tenloaiky "
 + " 	) "
 + " 	VALUES "
 + " 	( "
 + " 		'@Tenloaiky' "
 + " 	) ";
        public static string PRCTBLDM_HOCKY_GET = "SELECT"
 + " * "
 + " FROM "
 + " 	TblDm_Hocky ";
        public static string PRCTBLDM_HOCKY_UPDATE = "UPDATE TblDm_Hocky"
 + " SET "
 + " 	Tenloaiky = '@Tenloaiky' "
 + " WHERE "
 + " 	Id =@Id";
        public static string PRCTBLDM_LOGIN_GET = "   if @Option=1"
 + " 		SELECT     ID_User, ID_Quyen, ID_Control, PhanQuyen "
 + " 		FROM         Quyen "
 + " 		WHERE     (ID_User = @IdUser) "
 + "   if @Option=2 "
 + " 		SELECT     Control.nameControl, Quyen.ID_Quyen, Quyen.ID_User, Quyen.ID_Control, Quyen.PhanQuyen "
 + " 		FROM         Control INNER JOIN "
 + " 		                      Quyen ON Control.ID_Control = Quyen.ID_Control "
 + " 		WHERE     (Quyen.ID_User = @IdUser) ";
        public static string PRCTBLDM_LOPIDBYNAMTREHOCID = "SELECT"
 + " 	TblNamtrehoc.LophocId, "
 + " 		TblNamtrehoc.Tinhtrang "
 + " FROM "
 + " 	TblNamtrehoc "
 + " where (TblNamtrehoc.Tinhtrang =0 and TblNamtrehoc.Id =@NamtrehocId ) ";
        public static string PRCTBLDM_NAMHOC_SELECT = "SELECT Tennamhoc FROM TblDm_Namhoc WHERE Trangthai = 1";
        public static string PRCTBLDM_NHAPTRONGNGAY_SELECT = "		SELECT     TblDm_Donvitinh.Tendonvitinh,  TblDm_Donvitinh.Id AS idDVT,"
 + " 		                       TblThucpham_thucan.Tenthucan, TblNhapxuathanghoa.Soluong, TblNhapxuathanghoa.Dongia,  "
 + " 		                      TblNhapxuathanghoa.Dongia * TblNhapxuathanghoa.Soluong AS Tongtien, TblThucpham_thucan.Id AS IdMonAn, TblNhapxuathanghoa.Soluongcon "
 + " 		FROM         TblDm_Donvitinh INNER JOIN "
 + " 		                      TblThucpham_thucan ON TblDm_Donvitinh.Id = TblThucpham_thucan.DonvitinhId INNER JOIN "
 + " 		                      TblNhapxuathanghoa ON TblDm_Donvitinh.Id = TblNhapxuathanghoa.DonvitinhId AND  "
 + " 		                      TblThucpham_thucan.Id = TblNhapxuathanghoa.Thucpham_ThucanId INNER JOIN "
 + " 		                      TblDm_Nhomthucpham_thucan ON TblThucpham_thucan.NhomthucanId = TblDm_Nhomthucpham_thucan.Id "
 + " 		WHERE     (TblNhapxuathanghoa.HoadonnhapxuatId = @Id_Nhom) ";
        public static string PRCTBLDM_NHUCAUDINHDUONG = "			SELECT   TblThucpham_thucan.Tenthucan, TblDm_Donvitinh.Tendonvitinh, TblHoadonnhapxuat.Trangthai, TblNhapxuathanghoa.Soluong, "
 + "                       TblThucpham_thucan.Calo, TblThanhphanhoahoc.Tphh_Protid, TblThanhphanhoahoc.Tphh_Lipid, TblThanhphanhoahoc.Tphh_GlucId,  "
 + "                       TblThanhphanhoahoc.Tphh_Cellulose, TblThucpham_thucan.Nguyenlieu, TblThucpham_thucan.Nguondongvat "
 + "              FROM     TblThucpham_thucan INNER JOIN "
 + "                       TblNhapxuathanghoa ON TblThucpham_thucan.Id = TblNhapxuathanghoa.Thucpham_ThucanId INNER JOIN "
 + "                       TblHoadonnhapxuat ON TblNhapxuathanghoa.HoadonnhapxuatId = TblHoadonnhapxuat.Id INNER JOIN "
 + "                       TblDm_Donvitinh ON TblThucpham_thucan.DonvitinhId = TblDm_Donvitinh.Id INNER JOIN "
 + "                       TblThanhphanhoahoc ON TblThucpham_thucan.Id = TblThanhphanhoahoc.IdThucpham_thucan "
 + "              WHERE     (TblHoadonnhapxuat.Trangthai = 0) ";
        public static string PRCTBLDM_NHUCAUDINHDUONGOTRUONG_DEL = "	 delete from TblDm_Nhucaudinhduongotruong where (KhoilopId =@KhoilopId)";
        public static string PRCTBLDM_NHUCAUDINHDUONGOTRUONG_GET = "	SELECT      KhoilopId, KCaloCd, KCaloCtr, ProtidCd, ProtidCtr, LipidCd, LipidCtr, GlucidCd, GlucidCtr, Vungmien, Id"
 + " FROM         TblDm_Nhucaudinhduongotruong "
 + " WHERE     (Vungmien = @Vungmien) "
 + " ORDER BY KhoilopId ";
        public static string PRCTBLDM_NHUCAUDINHDUONGOTRUONG_GETBYKHOILOPID = "	SELECT     KhoilopId, isnull(KCaloCd,0) as KCaloCd,isnull( KCaloCtr,0) as KCaloCtr,isnull( ProtidCd,0) as ProtidCd,isnull( ProtidCtr,0) as ProtidCtr, isnull(LipidCd,0) as LipidCd,isnull( LipidCtr,0) as LipidCtr,isnull( GlucidCd,0) as GlucidCd,isnull( GlucidCtr,0) as GlucidCtr"
 + " FROM         TblDm_Nhucaudinhduongotruong "
 + " WHERE     (KhoilopId = @KhoilopId) and Vungmien =@Vungmien ";
        public static string PRCTBLDM_NHUCAUDINHDUONGOTRUONG_INSERT = "	 INSERT INTO TblDm_Nhucaudinhduongotruong"
 + " 	                       (KhoilopId,KCaloCd, KCaloCtr, ProtidCd, ProtidCtr, LipidCd, LipidCtr, GlucidCd, GlucidCtr,Vungmien) "
 + " 	 VALUES     (@KhoilopId,@KCaloCd,@KCaloCtr,@ProtidCd,@ProtidCtr,@LipidCd,@LipidCtr,@GlucidCd,@GlucidCtr,@Vungmien) ";
        public static string PRCTBLDM_NHUCAUDINHDUONGOTRUONG_SELECALL = "	SELECT DISTINCT "
 + "                        iif(ISNULL(TblDm_Nhucaudinhduongotruong.KCaloCd), 0,TblDm_Nhucaudinhduongotruong.KCaloCd) AS KCaloCd, iif(ISNULL(TblDm_Nhucaudinhduongotruong.KCaloCtr), 0,TblDm_Nhucaudinhduongotruong.KCaloCtr)  "
 + "                       AS KCaloCtr, iif(ISNULL(TblDm_Nhucaudinhduongotruong.ProtidCd), 0,TblDm_Nhucaudinhduongotruong.ProtidCd) AS ProtidCd, iif(ISNULL(TblDm_Nhucaudinhduongotruong.ProtidCtr), 0,TblDm_Nhucaudinhduongotruong.ProtidCtr)  "
 + "                       AS ProtidCtr, iif(ISNULL(TblDm_Nhucaudinhduongotruong.LipidCd), 0,TblDm_Nhucaudinhduongotruong.LipidCd) AS LipidCd, iif(ISNULL(TblDm_Nhucaudinhduongotruong.LipidCtr), 0,TblDm_Nhucaudinhduongotruong.LipidCtr)  "
 + "                       AS LipidCtr, iif(ISNULL(TblDm_Nhucaudinhduongotruong.GlucidCd), 0,TblDm_Nhucaudinhduongotruong.GlucidCd) AS GlucidCd, iif(ISNULL(TblDm_Nhucaudinhduongotruong.GlucidCtr), 0,TblDm_Nhucaudinhduongotruong.GlucidCtr)  "
 + "                       AS GlucidCtr, TblDm_Nhucaudinhduongotruong.KhoilopId, TblDm_Khoilop.Tenkhoilop, TblDm_Nhucaudinhduongotruong.Id,  "
 + "                       TblDm_Nhucaudinhduongotruong.Vungmien "
 + " FROM         TblDm_Khoilop LEFT OUTER JOIN "
 + "                       TblDm_Nhucaudinhduongotruong ON TblDm_Khoilop.Id = TblDm_Nhucaudinhduongotruong.KhoilopId "
 + " WHERE     (TblDm_Nhucaudinhduongotruong.Vungmien = @Vungmien) "
 + " ORDER BY TblDm_Nhucaudinhduongotruong.KhoilopId ";
        public static string PRCTBLDM_NHUCAUDINHDUONGOTRUONG_UPDATE = "	  UPDATE    TblDm_Nhucaudinhduongotruong"
 + " 	  SET              KCaloCd = @KCaloCd, KCaloCtr = @KCaloCtr, ProtidCd = @ProtidCd, ProtidCtr = @ProtidCtr, LipidCd = @LipidCd, LipidCtr = @LipidCtr,  "
 + " 	                        GlucidCd = @GlucidCd, GlucidCtr = @GlucidCtr "
 + " 	  WHERE    (  Id = @Id) ";
        public static string PRCTBLDM_NHUCAUNANGLUONG_PROTEININSERT = "	RETURN";
        public static string PRCTBLDM_NHUCAUNANGLUONG_PROTEINSELECTALL = "	RETURN";
        public static string PRCTBLDM_NHUCAUNANGLUONG_PROTEINUPDATE = "	RETURN";
        public static string PRCTBLDM_NHUNANGLUONG_PROTEINGET = "SELECT TblDm_Nhucaunangluong_protein.* FROM TblDm_Nhucaunangluong_protein ";

        public static string PRCTBLDM_PHANLOAILOP = "SELECT Id, Tenloailop, Cantuoi1, Cantuoi2 FROM TblDm_Phanloailop WHERE Id = ? ";
        public static string PRCTBLDM_PHANLOAILOP_ADD = "INSERT INTO TblDm_Phanloailop (Tenloailop, Cantuoi1, Cantuoi2, KhoilopId) VALUES (?, ?, ?, ?) ";
        public static string PRCTBLDM_PHANLOAILOP_DEL = "delete from TblDm_Phanloailop where Id = ? ";
        public static string PRCTBLDM_PHANLOAILOP_GET = "SELECT * FROM TblDm_Phanloailop ORDER BY Cantuoi1";
        public static string PRCTBLDM_PHANLOAILOP_UPDATE = "UPDATE TblDm_Phanloailop SET Tenloailop = '@Ten', Cantuoi1 = '@Cantuoi1', Cantuoi2 = '@Cantuoi2' WHERE Id = @Id";

        public static string PRCTBLDM_QUOCTICH_ADD = "INSERT INTO TblDm_Quoctich(Tenquoctich) VALUES ( ? ) ";
        public static string PRCTBLDM_QUOCTICH_DEL = "delete from TblDm_Quoctich where Id = ? ";
        public static string PRCTBLDM_QUOCTICH_GET = "SELECT * FROM TblDm_Quoctich ORDER BY Tenquoctich ";
        public static string PRCTBLDM_QUOCTICH_UPDATE = "UPDATE TblDm_Quoctich SET Tenquoctich = '@Ten' WHERE Id =@Id";

        public static string PRCTBLDM_SOSANHDINHDUONG_SELECTALL1 = " 	SELECT     TblThucpham_thucan.Id AS IdThucPham, TblThucpham_thucan.Tenthucan, iif( isnull(TblThucpham_thucan.Tylequydoi),1,TblThucpham_thucan.Tylequydoi) as Tylequydoi, iif( isnull(TblThucpham_thucan.Tylethai),0,TblThucpham_thucan.Tylethai) as Tylethai,                 iif( isnull(TblThucpham_thucan.Calo),0,TblThucpham_thucan.Calo) as Calo, iif( isnull(TblThanhphanhoahoc.Tphh_Protid), 0,TblThanhphanhoahoc.Tphh_Protid) as  Tphh_Protid,iif( isnull(TblThanhphanhoahoc.Tphh_Lipid),0,TblThanhphanhoahoc.Tphh_Lipid) as Tphh_Lipid, iif(isnull(TblThanhphanhoahoc.Tphh_GlucId),0,TblThanhphanhoahoc.Tphh_GlucId) as Tphh_GlucId,     TblDm_Donvitinh.Tendonvitinh " +
 " FROM     (    TblThanhphanhoahoc INNER JOIN                       TblThucpham_thucan ON TblThanhphanhoahoc.IdThucpham_thucan = TblThucpham_thucan.Id) " +
 " INNER JOIN                      TblDm_Donvitinh ON TblThucpham_thucan.DonvitinhId = TblDm_Donvitinh.Id   WHERE     (TblThucpham_thucan.Tenthucan = @Name)  	  "


;

        public static string PRCTBLDM_SOSANHDINHDUONG_SELECTALL = "	  if @Option=1"
 + " 			SELECT     TblThucpham_thucan.Id AS IdThucPham, TblThucpham_thucan.Tenthucan, isnull(TblThucpham_thucan.Tylequydoi,1) as Tylequydoi, isnull(TblThucpham_thucan.Tylethai,0) as Tylethai,  "
 + " 			                      isnull(TblThucpham_thucan.Calo,0) as Calo, isnull(TblThanhphanhoahoc.Tphh_Protid, 0) as  Tphh_Protid, isnull(TblThanhphanhoahoc.Tphh_Lipid,0) as Tphh_Lipid, isnull(TblThanhphanhoahoc.Tphh_GlucId,0) as Tphh_GlucId,  "
 + " 			                      TblDm_Donvitinh.Tendonvitinh "
 + " 			FROM         TblThanhphanhoahoc INNER JOIN "
 + " 			                      TblThucpham_thucan ON TblThanhphanhoahoc.IdThucpham_thucan = TblThucpham_thucan.Id INNER JOIN "
 + " 			                      TblDm_Donvitinh ON TblThucpham_thucan.DonvitinhId = TblDm_Donvitinh.Id "
 + " 			WHERE     (TblThucpham_thucan.Tenthucan = @Name)       "
 + " 	 /*        --------------------------------                         */ "
 + " 	 /*      Đoạn chương trình này dùng để lấy nhu cầu dinh dưỡng của trẻ ở trường theo lứa tuổi cũng như theo lớp  ---*/ "
 + " 	 /*			--------------------------------						*/ "
 + " 	   /*-------------------------Đoạn nè đùng để load lấy ra ID của lớp---------------------------------*/ "
 + " 	 if @Option=3 "
 + " 		   SELECT     TblLop.Id AS IdLop, TblDm_Phanloailop.Id AS IdPhanLoaiLop "
 + " 		   FROM         TblLop INNER JOIN "
 + " 		                         TblDm_Phanloailop ON TblLop.PhanloailopId = TblDm_Phanloailop.Id "
 + " 		   WHERE     (TblLop.Id = @Id) "

;
        public static string PRCTBLDM_SUCKHOETHANG_INSERT = "INSERT INTO TblDm_Suckhoethangtuoi(KenhId, Tenthangtuoi, Cantuoiduoi, Cantuoitren, Gioitinh) VALUES (?, ?, ?, ?, ?) ";
        public static string PRCTBLDM_SUCKHOETHANGTUOI = "	SELECT Id, KenhId, Tenthangtuoi, Cantuoiduoi, Cantuoitren, Gioitinh FROM TblDm_Suckhoethangtuoi WHERE Tenthangtuoi = ? ";
        public static string PRCTBLDM_SUCKHOETHANGTUOI_DELETE = "DELETE FROM TblDm_Suckhoethangtuoi WHERE Id = ? ";
        public static string PRCTBLDM_SUCKHOETHANGTUOI_GET = "	SELECT TblDm_Kenh.Tenkenh, TblDm_Suckhoethangtuoi.Id, TblDm_Suckhoethangtuoi.Tenthangtuoi, TblDm_Suckhoethangtuoi.Cantuoiduoi, TblDm_Suckhoethangtuoi.Cantuoitren, TblDm_Suckhoethangtuoi.Gioitinh, TblDm_Suckhoethangtuoi.KenhId FROM TblDm_Suckhoethangtuoi INNER JOIN TblDm_Kenh ON TblDm_Suckhoethangtuoi.KenhId = TblDm_Kenh.Id ";
        public static string PRCTBLDM_SUCKHOETHANGTUOI_UPDATE = "UPDATE TblDm_Suckhoethangtuoi SET KenhId = ?, Tenthangtuoi = ?, Cantuoiduoi = ?, Cantuoitren = ?, Gioitinh = ? WHERE Id = ? ";

        public static string PRCTBLDM_THANHPHANDINHDUONG_BYNHOMID_TENTHUCAN = "	SELECT     TblThucpham_thucan.Tenthucan, TblDm_Donvitinh.Tendonvitinh, "
 + "   TblThucpham_thucan.Calo, TblThanhphanhoahoc.Tphh_Protid, TblThanhphanhoahoc.Tphh_Lipid, TblThanhphanhoahoc.Tphh_GlucId,  "
 + "   TblThanhphanhoahoc.Tphh_Nuoc, TblThanhphanhoahoc.Tphh_Cellulose, TblThanhphanhoahoc.Tphh_Tro,  "
 + "   TblThanhphanhoahoc.Tpmk_Natri, TblThanhphanhoahoc.Tpmk_Kali, TblThanhphanhoahoc.Tpmk_Calci,  "
 + "   TblThanhphanhoahoc.Tpmk_Photpho, TblThanhphanhoahoc.Tpmk_Fe, TblThanhphanhoahoc.Tpmk_Axitfomic,  "
 + "   TblThanhphanhoahoc.Tpvitamin_VitaminA, TblThanhphanhoahoc.Tpvitamin_VitaminC,  "
 + "   TblThanhphanhoahoc.Tpvitamin_PP, TblThanhphanhoahoc.Tpvitamin_Caroten,  "
 + "   TblDm_Nhomthucpham_thucan.Id AS Nhom,  "
 + "   TblThucpham_thucan.Nguyenlieu, TblThucpham_thucan.Nguondongvat,  "
 + "   TblThucpham_thucan.Tylethai,	TblThucpham_thucan.Tylequydoi, TblThucpham_thucan.Nam, TblThucpham_thucan.Id "
 + " FROM ((TblDm_Nhomthucpham_thucan INNER JOIN "
 + "       TblThucpham_thucan ON TblDm_Nhomthucpham_thucan.Id = TblThucpham_thucan.NhomthucanId) INNER JOIN "
 + "       TblThanhphanhoahoc ON TblThucpham_thucan.Id = TblThanhphanhoahoc.IdThucpham_thucan) INNER JOIN "
 + "       TblDm_Donvitinh ON TblThucpham_thucan.DonvitinhId = TblDm_Donvitinh.Id "
 + " WHERE  TblThucpham_thucan.Tenthucan LIKE '?' AND TblDm_Nhomthucpham_thucan.Id = ? "
;
        public static string PRCTBLDM_THANHPHANDINHDUONG_SELECTBYNAME = "SELECT TblThucpham_thucan.Tenthucan, TblDm_Donvitinh.Tendonvitinh, "
 + "  TblThucpham_thucan.Calo, TblThanhphanhoahoc.Tphh_Protid, TblThanhphanhoahoc.Tphh_Lipid, TblThanhphanhoahoc.Tphh_GlucId, "
 + "  TblThanhphanhoahoc.Tphh_Nuoc, TblThanhphanhoahoc.Tphh_Cellulose, TblThanhphanhoahoc.Tphh_Tro, "
 + "  TblThanhphanhoahoc.Tpmk_Natri, TblThanhphanhoahoc.Tpmk_Kali, TblThanhphanhoahoc.Tpmk_Calci, "
 + "  TblThanhphanhoahoc.Tpmk_Photpho, TblThanhphanhoahoc.Tpmk_Fe, TblThanhphanhoahoc.Tpmk_Axitfomic, "
 + "  TblThanhphanhoahoc.Tpvitamin_VitaminA, TblThanhphanhoahoc.Tpvitamin_VitaminC, "
 + "  TblThanhphanhoahoc.Tpvitamin_PP, TblThanhphanhoahoc.Tpvitamin_Caroten, "
 + "  TblDm_Nhomthucpham_thucan.Id AS Nhom, TblThucpham_thucan.Nguyenlieu, TblThucpham_thucan.Nguondongvat, "
 + "  TblThucpham_thucan.Tylethai, TblThucpham_thucan.Tylequydoi, TblThucpham_thucan.Nam, TblThucpham_thucan.Id "
 + " FROM ((TblDm_Nhomthucpham_thucan INNER JOIN "
 + "  TblThucpham_thucan ON TblDm_Nhomthucpham_thucan.Id = TblThucpham_thucan.NhomthucanId) INNER JOIN "
 + "  TblThanhphanhoahoc ON TblThucpham_thucan.Id = TblThanhphanhoahoc.IdThucpham_thucan) INNER JOIN "
 + "  TblDm_Donvitinh ON TblThucpham_thucan.DonvitinhId = TblDm_Donvitinh.Id "
 + " WHERE TblDm_Nhomthucpham_thucan.Id = ? ";
        public static string PRCTBLDM_THANHPHANDINHDUONG_SELECTALL = "SELECT TblThucpham_thucan.Tenthucan, TblDm_Donvitinh.Tendonvitinh, "
 + "  TblThucpham_thucan.Calo, TblThanhphanhoahoc.Tphh_Protid, TblThanhphanhoahoc.Tphh_Lipid, TblThanhphanhoahoc.Tphh_GlucId, "
 + "  TblThanhphanhoahoc.Tphh_Nuoc, TblThanhphanhoahoc.Tphh_Cellulose, TblThanhphanhoahoc.Tphh_Tro, "
 + "  TblThanhphanhoahoc.Tpmk_Natri, TblThanhphanhoahoc.Tpmk_Kali, TblThanhphanhoahoc.Tpmk_Calci, "
 + "  TblThanhphanhoahoc.Tpmk_Photpho, TblThanhphanhoahoc.Tpmk_Fe, TblThanhphanhoahoc.Tpmk_Axitfomic, "
 + "  TblThanhphanhoahoc.Tpvitamin_VitaminA, TblThanhphanhoahoc.Tpvitamin_VitaminC, "
 + "  TblThanhphanhoahoc.Tpvitamin_PP, TblThanhphanhoahoc.Tpvitamin_Caroten, "
 + "  TblDm_Nhomthucpham_thucan.Id AS Nhom, TblThucpham_thucan.Nguyenlieu, TblThucpham_thucan.Nguondongvat, "
 + "  TblThucpham_thucan.Tylethai, TblThucpham_thucan.Tylequydoi, TblThucpham_thucan.Nam, TblThucpham_thucan.Id "
 + " FROM ((TblDm_Nhomthucpham_thucan INNER JOIN "
 + "  TblThucpham_thucan ON TblDm_Nhomthucpham_thucan.Id = TblThucpham_thucan.NhomthucanId) INNER JOIN "
 + "  TblThanhphanhoahoc ON TblThucpham_thucan.Id = TblThanhphanhoahoc.IdThucpham_thucan) INNER JOIN "
 + "  TblDm_Donvitinh ON TblThucpham_thucan.DonvitinhId = TblDm_Donvitinh.Id ";
        public static string PRCTBLDM_THANHPHANDINHDUONGTHUCAN_DELETE = "DELETE FROM TblThucpham_thucan WHERE Id = ? ";
        public static string PRCTBLDM_THANHPHANDINHDUONGTHUCAN_SELECTALL = "	 SELECT     TblThucpham_thucan.Id, TblThucpham_thucan.Tenthucan, TblThucpham_thucan.Tylequydoi, TblDm_Donvitinh.Tendonvitinh, "
 + " 	                       TblThucpham_thucan.Tylethai, TblThucpham_thucan.Calo, TblThucpham_thucan.Nguyenlieu, TblThucpham_thucan.Nguondongvat,  "
 + " 	                       TblThucpham_thucan.Nam, TblThanhphanhoahoc.Tphh_Nuoc, TblThanhphanhoahoc.Tphh_Protid, TblThanhphanhoahoc.Tphh_Lipid,  "
 + " 	                       TblThanhphanhoahoc.Tphh_GlucId, TblThanhphanhoahoc.Tphh_Cellulose, TblThanhphanhoahoc.Tphh_Tro, TblThanhphanhoahoc.Tpmk_Calci,  "
 + " 	                       TblThanhphanhoahoc.Tpmk_Photpho, TblThanhphanhoahoc.Tpmk_Fe, TblThanhphanhoahoc.Tpvitamin_Caroten,  "
 + " 	                       TblThanhphanhoahoc.Tpvitamin_VitaminA, TblThanhphanhoahoc.Tpvitamin_VitaminB1, TblThanhphanhoahoc.Tpvitamin_VitaminB2,  "
 + " 	                       TblThanhphanhoahoc.Tpvitamin_PP, TblThanhphanhoahoc.Tpvitamin_VitaminC, TblDm_Nhomthucpham_thucan.Tennhom,  "
 + " 	                       TblDm_Nhomthucpham_thucan.Id AS Expr1, TblThanhphanhoahoc.Tpmk_Natri, TblThanhphanhoahoc.Tpmk_Kali,  "
 + " 	                       TblThanhphanhoahoc.Tpmk_Axitfomic, TblDm_Donvitinh.Id AS IdDonVitinh, TblThucpham_thucan.NhomthucanId "
 + " 	 FROM         TblDm_Nhomthucpham_thucan INNER JOIN "
 + " 	                       TblThucpham_thucan ON TblDm_Nhomthucpham_thucan.Id = TblThucpham_thucan.NhomthucanId INNER JOIN "
 + " 	                       TblThanhphanhoahoc ON TblThucpham_thucan.Id = TblThanhphanhoahoc.IdThucpham_thucan INNER JOIN "
 + " 	                       TblDm_Donvitinh ON TblThucpham_thucan.DonvitinhId = TblDm_Donvitinh.Id "
 + " 	 WHERE     (TblThucpham_thucan.Id = @id_Nhom) ";
        public static string PRCTBLDM_THANHPHANHOAHOC_INSERT = " INSERT INTO TblThanhphanhoahoc"
 + "  (  IdThucpham_thucan,  Tphh_Nuoc,          Tphh_Protid,         Tphh_Lipid,          Tphh_GlucId, "
 + "     Tphh_Cellulose,     Tphh_Tro,           Tpmk_Calci,          Tpmk_Photpho,        Tpmk_Fe,  "
 + "     Tpvitamin_Caroten,  Tpvitamin_VitaminA, Tpvitamin_VitaminB1, Tpvitamin_VitaminB2, Tpvitamin_PP, "
 + "     Tpvitamin_VitaminC, Tpmk_Natri, Tpmk_Kali,    Tpmk_Axitfomic) "
 + " VALUES  ( ?,            ?,                  ?,                   ?,                   ?, "
 + "     ?,                  ?,                  ?,                   ?,                   ?, "
 + "     ?,                  ?,                  ?,                   ?,                   ?, "
 + "     ?,                  ?,          ?,            ?) ";
        public static string PRCTBLDM_THANHPHANHOAHOC_UPDATE = "	UPDATE    TblThanhphanhoahoc"
 + " 	SET              IdThucpham_thucan = @IdThucpham_thucan, Tphh_Nuoc = @Tphh_Nuoc, Tphh_Protid = @Tphh_Protid, Tphh_Lipid = @Tphh_Lipid,  "
 + " 	                      Tphh_GlucId = @Tphh_GlucId, Tphh_Cellulose = @Tphh_Cellulose, Tphh_Tro = @Tphh_Tro, Tpmk_Calci = @Tpmk_Calci,  "
 + " 	                      Tpmk_Photpho = @Tpmk_Photpho, Tpmk_Fe = @Tpmk_Fe, Tpvitamin_Caroten = @Tpvitamin_Caroten, Tpvitamin_VitaminA = @Tpvitamin_VitaminA,  "
 + " 	                      Tpvitamin_VitaminB1 = @Tpvitamin_VitaminB1, Tpvitamin_VitaminB2 = @Tpvitamin_VitaminB2, Tpvitamin_PP = @Tpvitamin_PP,  "
 + " 	                      Tpvitamin_VitaminC = @Tpvitamin_VitaminC, Tpmk_Natri = @Tpmk_Natri, Tpmk_Kali = @Tpmk_Kali, Tpmk_Axitfomic = @Tpmk_Axitfomic "
 + " 	WHERE     (IdThucpham_thucan = @IdThucpham_thucan) ";
        public static string PRCTBLDM_THANHPHANHOCHOC_DELETE = "DELETE FROM TblThanhphanhoahoc WHERE IdThucpham_thucan = ? ";
        public static string PRCTBLDM_THEMNGUOISUDUNG_GET = "	  if @Option =1"
 + " 			 SELECT     ID_Control "
 + " 			 FROM         Control "
 + " 			 WHERE     (nameControl = @NameControl) ";
        public static string PRCTBLDM_THEMNNGUOISUDUNG_SELECTALL = "	  if @Option=1"
 + " 			SELECT     User.* "
 + " 			FROM         User ";
        public static string PRCTBLDM_TO_DEL = "	"
 + " 	delete  from TblDm_To where  (Id = @Id) ";
        public static string PRCTBLDM_TONGHOPDINHDUONG = "  if @Option=1"
 + " 			SELECT   TblThucpham_thucan.Tenthucan, TblDm_Donvitinh.Tendonvitinh, TblHoadonnhapxuat.Trangthai, TblNhapxuathanghoa.Soluong,  "
 + "                       TblThucpham_thucan.Calo, TblThanhphanhoahoc.Tphh_Protid, TblThanhphanhoahoc.Tphh_Lipid, TblThanhphanhoahoc.Tphh_GlucId,  "
 + "                      TblThanhphanhoahoc.Tphh_Cellulose, TblThucpham_thucan.Nguyenlieu, TblThucpham_thucan.Nguondongvat,TblHoadonnhapxuat.NgayNX "
 + "              FROM     TblThucpham_thucan INNER JOIN "
 + "                       TblNhapxuathanghoa ON TblThucpham_thucan.Id = TblNhapxuathanghoa.Thucpham_ThucanId INNER JOIN "
 + "                       TblHoadonnhapxuat ON TblNhapxuathanghoa.HoadonnhapxuatId = TblHoadonnhapxuat.Id INNER JOIN "
 + "                       TblDm_Donvitinh ON TblThucpham_thucan.DonvitinhId = TblDm_Donvitinh.Id INNER JOIN "
 + "                       TblThanhphanhoahoc ON TblThucpham_thucan.Id = TblThanhphanhoahoc.IdThucpham_thucan "
 + "              WHERE  (TblHoadonnhapxuat.NgayNX BETWEEN @StartDay AND @FinishDay )  AND "
 + " 					(TblHoadonnhapxuat.Trangthai = 0)  "
 + "    if @Option=2 "
 + " 		SELECT     Ngay, Tongsosuat, Tongsotre "
 + "         FROM       TblBaoan	 "
 + "         WHERE      (Ngay   BETWEEN  @StartDay AND @FinishDay ) ";

        public static string PRCTBLDM_TONGHOPDINHDUONG1 = " 		SELECT   TblThucpham_thucan.Tenthucan, TblDm_Donvitinh.Tendonvitinh, TblHoadonnhapxuat.Trangthai, TblNhapxuathanghoa.Soluong,                         TblThucpham_thucan.Calo, TblThanhphanhoahoc.Tphh_Protid, TblThanhphanhoahoc.Tphh_Lipid, TblThanhphanhoahoc.Tphh_GlucId,                        TblThanhphanhoahoc.Tphh_Cellulose, TblThucpham_thucan.Nguyenlieu, TblThucpham_thucan.Nguondongvat,TblHoadonnhapxuat.NgayNX             " +
  " FROM  ( ((  TblThucpham_thucan INNER JOIN     TblNhapxuathanghoa ON TblThucpham_thucan.Id = TblNhapxuathanghoa.Thucpham_ThucanId) "
  + " INNER JOIN     TblHoadonnhapxuat ON TblNhapxuathanghoa.HoadonnhapxuatId = TblHoadonnhapxuat.Id) "
 + " INNER JOIN       TblDm_Donvitinh ON TblThucpham_thucan.DonvitinhId = TblDm_Donvitinh.Id) "
 + " INNER JOIN    TblThanhphanhoahoc ON TblThucpham_thucan.Id = TblThanhphanhoahoc.IdThucpham_thucan              "
 + " WHERE  (TblHoadonnhapxuat.NgayNX BETWEEN @StartDay AND @FinishDay )  AND (TblHoadonnhapxuat.Trangthai = 0)  ";

        public static string PRCTBLDM_TONGHOPDINHDUONG2 = " select DISTINCT TblBaoan.LophocId, TblBaoan.Id, TblBaoan.ThanghocId, TblBaoan.Ngay, TblBaoan.Tongsosuat, TblBaoan.Tongsotre "
+ "         FROM       TblBaoan	 "
+ "         WHERE      (Ngay   in (SELECT TblHoadonnhapxuat.NgayNX FROM TblHoadonnhapxuat WHERE TblHoadonnhapxuat.Trangthai=0 and  TblHoadonnhapxuat.NgayNX  BETWEEN  @StartDay AND @FinishDay and TblHoadonnhapxuat.NamhocId =@NamhocId )) ";

        public static string PRCTBLDM_UPDATESOLUONGCON = "	RETURN";
        public static string PRCTBLDM_XEPLOAITOBYTOID = "	"
 + " 	SELECT     Id, ToId, Xeploai, HockyId, NamhocId "
 + " FROM         Tbl_Totrongnam "
 + " WHERE     (ToId = @ToId) AND (NamhocId = ?) ";
        public static string PRCTBTBL_SELECTTENBUAANTONG = "			SELECT     TblThucpham_thucan.NhomthucanId, TblThucpham_thucan.Tenthucan, TblLenthucphammonanchobua.BaoanId, "
 + " 			                      ROUND(TblLenthucphammonanchobua.Soluong, 5) AS Soluong, TblThucpham_thucan.DonvitinhId, TblDm_Donvitinh.Tendonvitinh,  "
 + " 			                      TblLenthucphammonanchobua.Dongiathucte "
 + " 			FROM         TblThucpham_thucan INNER JOIN "
 + " 			                      TblLenthucphammonanchobua ON TblThucpham_thucan.Id = TblLenthucphammonanchobua.Thucpham_ThucanId INNER JOIN "
 + " 			                      TblDm_Donvitinh ON TblThucpham_thucan.DonvitinhId = TblDm_Donvitinh.Id "
 + " 			WHERE     (TblLenthucphammonanchobua.BaoanId = @Id) ";
        public static string PROC_BIEUDOSUCKHOE = "SELECT      TblDm_Thanghoc.Thang, TblTrekiemtrasuckhoe.Chieucao, TblTrekiemtrasuckhoe.Cannang,                        TblDm_Thanghoc.NamhocId, TblTre.Hovaten, TblLop.Tenlop " +
 " FROM     (( (TblTrekiemtrasuckhoe INNER JOIN                        TblDm_Thanghoc ON TblTrekiemtrasuckhoe.ThanghocId = TblDm_Thanghoc.Id )" +
" INNER JOIN                        TblNamtrehoc ON TblTrekiemtrasuckhoe.NamtrehocId = TblNamtrehoc.Id) " +
" INNER JOIN                        TblLop ON TblNamtrehoc.LophocId = TblLop.Id) " +
" INNER JOIN                        TblTre ON TblNamtrehoc.TreId = TblTre.Id  WHERE     (TblDm_Thanghoc.NamhocId =@NamhocId) AND (TblTrekiemtrasuckhoe.NamtrehocId = @NamtrehocId)  ORDER BY TblDm_Thanghoc.Nam, TblDm_Thanghoc.Thang ";


        public static string PROC_TBL_TOTRONGNAM_BYXEPLOAI = "SELECT     ToId, Xeploai, HockyId, NamhocId"
 + " FROM         Tbl_Totrongnam "
 + " WHERE     (Xeploai LIKE '%?%') ";
        public static string PROC_TBLBANGCAP_BYHEDAOTAOID = "SELECT     NhanvienId, Tentruong, Loaitotnghiep, Chuyennganhdaotao, HedaotaoId, Namtotnghiep, LoaihinhdaotaoId"
 + " FROM         TblBangcap "
 + " WHERE     (HedaotaoId = ?) ";
        public static string PROC_TBLBANGCAPBYHEDAOTAOID = "SELECT     NhanvienId, Tentruong, Loaitotnghiep, Chuyennganhdaotao, HedaotaoId, Namtotnghiep, LoaihinhdaotaoId"
 + " FROM         TblBangcap "
 + " WHERE     (HedaotaoId = ?) ";
        public static string PROC_TBLCHITIETHOADONNHAPXUAT = "SELECT     TblNhapxuathanghoa.Id, TblNhapxuathanghoa.HoadonnhapxuatId, TblNhapxuathanghoa.DonvitinhId, "
 + "                       TblNhapxuathanghoa.Thucpham_ThucanId, TblNhapxuathanghoa.Soluong as Soluonglayxuat, TblNhapxuathanghoa.Soluongcon as Soluong,  "
 + "                       TblNhapxuathanghoa.Dongia "
 + " FROM         TblHoadonnhapxuat INNER JOIN "
 + "                       TblNhapxuathanghoa ON TblHoadonnhapxuat.Id = TblNhapxuathanghoa.HoadonnhapxuatId "
 + " WHERE     (TblHoadonnhapxuat.Trangthai = 0) AND (TblHoadonnhapxuat.NgayNX = @NgayNX) and "
 + "  TblNhapxuathanghoa.Thucpham_ThucanId =? ";
        public static string PROC_TBLCHITIETNHAPBYSOHOADONID = "SELECT     TblNhapxuathanghoa.HoadonnhapxuatId, TblThucpham_thucan.Tenthucan, TblNhapxuathanghoa.DonvitinhId, "
 + "                       TblNhapxuathanghoa.Thucpham_ThucanId, TblNhapxuathanghoa.Soluong, TblDm_Donvitinh.Tendonvitinh,  "
 + "                       TblNhapxuathanghoa.Soluongcon, TblNhapxuathanghoa.Dongia "
 + " FROM         TblHoadonnhapxuat INNER JOIN "
 + "                       TblNhapxuathanghoa ON TblHoadonnhapxuat.Id = TblNhapxuathanghoa.HoadonnhapxuatId INNER JOIN "
 + "                       TblThucpham_thucan ON TblNhapxuathanghoa.Thucpham_ThucanId = TblThucpham_thucan.Id INNER JOIN "
 + "                       TblDm_Donvitinh ON TblThucpham_thucan.DonvitinhId = TblDm_Donvitinh.Id "
 + " WHERE     (TblHoadonnhapxuat.Trangthai = 1) AND (TblNhapxuathanghoa.HoadonnhapxuatId = @HoadonnhapxuatId) ";
        public static string PROC_TBLDM_CHUCVU_DEL = "delete "
 + " FROM         TblDm_Chucvu "
 + " WHERE     (Id = @Id) ";
        public static string PROC_TBLDM_LOAIHOPDONG_DEL = "delete     "
 + " FROM         TblDm_Loaihopdong "
 + " WHERE     (Id = @Id) ";
        public static string PROC_TBLHOPDONGNHANVIENBYLOAIHOPDONGID = "SELECT     Id, NhanviencongtacId, LoaihopdongId, Ngayhopdong, Ghichu"
 + " FROM         TblHopdongnhanvien "
 + " WHERE     (LoaihopdongId = @LoaihopdongId) ";
        public static string PROC_TBLSOHOADONBYNGAYNX = "	SELECT     Id, NgayNX"
 + " FROM         TblHoadonnhapxuat "
 + " WHERE     (NgayNX = @NgayNX) AND (Trangthai = 1) ";
        public static string PROC_TBLTHUCPHAMTHUCANBYNHOMTHUCANID = "	SELECT     TblThucpham_thucan.Id AS IdThucpham_thucan, TblThucpham_thucan.Tenthucan, TblThucpham_thucan.DonvitinhId, "
 + "                       TblDm_Donvitinh.Tendonvitinh "
 + " FROM         TblThucpham_thucan INNER JOIN "
 + "                       TblDm_Donvitinh ON TblThucpham_thucan.DonvitinhId = TblDm_Donvitinh.Id "
 + " WHERE     (NhomthucanId = @NhomthucanId) ";
        public static string PROC_TBLTHUCPHAMTHUCANBYNHOMTHUCANIDANDTENTHUCAN = "	SELECT     TblThucpham_thucan.Id AS IdThucpham_thucan, TblThucpham_thucan.Tenthucan, TblThucpham_thucan.DonvitinhId, "
 + "                       TblDm_Donvitinh.Tendonvitinh "
 + " FROM         TblThucpham_thucan INNER JOIN "
 + "                       TblDm_Donvitinh ON TblThucpham_thucan.DonvitinhId = TblDm_Donvitinh.Id "
 + " WHERE     (NhomthucanId = @NhomthucanId) and  TblThucpham_thucan.Tenthucan like '%' + @Tenthucan+'%' ";
        public static string SEACHING = "	 /*------------------------- Seaching hóa đơn theo ngày tháng-----------------------------------------*/";

        public static string SP_PHIEUTIENAN_FINDBYLOPHOCIDNAMHOCIDTHANGHOCID_ = "if(@Tenlop ='')"
 + " if(@Varvalue =0) -- Chưa mua // la combotrangthai "
 + " SELECT     Tbl2.Hotendem, Tbl2.Ten, Tbl2.Hovaten, Tbl2.Tenthuonggoi, Tbl2.Ngaysinh, Tbl2.Noiohiennay, Tbl2.Gioitinh, Tbl2.Sodt, Tbl2.UutienId, Tbl2.Hotenbo,  "
 + "                       Tbl2.Nghenghiepbo, Tbl2.Hotenme, Tbl2.Nghengheme, Tbl2.Ghichu, Tbl2.Tinhtrang, Tbl2.NamtrehocId, Tbl2.Id, Tbl2.NamhocId "
 + " FROM         ( "
 + " 						SELECT      TblTre.Id, TblTre.Hotendem, TblTre.Ten, TblTre.Hovaten, TblTre.Tenthuonggoi, TblTre.Ngaysinh,  "
 + " 						  TblTre.Noiohiennay, TblTre.Gioitinh, TblTre.Sodt, TblTre.UutienId, TblTre.Hotenbo, TblTre.Nghenghiepbo,  "
 + " 						  TblTre.Hotenme, TblTre.Nghengheme, TblTre.Ghichu, TblTre.Tinhtrang, TblNamtrehoc.Id AS NamtrehocId,  "
 + " 						  TblPhieutienan.ThanghocId, TblNamtrehoc.NamhocId "
 + " 						FROM         TblTre INNER JOIN "
 + " 						  TblDm_Uutien ON TblDm_Uutien.Id = TblTre.UutienId INNER JOIN "
 + " 						  TblNamtrehoc ON TblTre.Id = TblNamtrehoc.TreId INNER JOIN "
 + " 						  TblPhieutienan ON TblNamtrehoc.Id = TblPhieutienan.NamtrehocId INNER JOIN "
 + " 						  TblLop ON TblNamtrehoc.LophocId = TblLop.Id "
 + " 						WHERE     (TblTre.Tinhtrang = 0) AND (TblTre.Hovaten LIKE '%' + @Hotendem + '%') AND (TblTre.Tenthuonggoi LIKE '%' + @Tenthuonggoi + '%') AND  "
 + " 						  (TblTre.Noiohiennay LIKE '%' + @Noiohiennay + '%') AND (TblTre.Gioitinh LIKE '%' + @Gioitinh + '%') AND  "
 + " 						  (TblPhieutienan.ThanghocId = ?) AND (TblLop.Tenlop LIKE '%' + @Tenlop + '%') "
 + " )  "
 + "                       AS Tbl1 RIGHT OUTER JOIN "
 + "   ( "
 + " 				SELECT      TblTre_1.Id, TblTre_1.Hotendem, TblTre_1.Ten, TblTre_1.Hovaten, TblTre_1.Tenthuonggoi, TblTre_1.Ngaysinh,  "
 + " 						  TblTre_1.Noiohiennay, TblTre_1.Gioitinh, TblTre_1.Sodt, TblTre_1.UutienId, TblTre_1.Hotenbo, TblTre_1.Nghenghiepbo, TblTre_1.Hotenme,  "
 + " 						  TblTre_1.Nghengheme, TblTre_1.Ghichu, TblTre_1.Tinhtrang, TblNamtrehoc_1.Id AS NamtrehocId, TblNamtrehoc_1.NamhocId "
 + " 				FROM         TblTre AS TblTre_1 INNER JOIN "
 + " 						  TblDm_Uutien AS TblDm_Uutien_1 ON TblDm_Uutien_1.Id = TblTre_1.UutienId INNER JOIN "
 + " 						  TblNamtrehoc AS TblNamtrehoc_1 ON TblTre_1.Id = TblNamtrehoc_1.TreId INNER JOIN "
 + " 						  TblLop AS TblLop_1 ON TblNamtrehoc_1.LophocId = TblLop_1.Id "
 + " 				WHERE     (TblTre_1.Tinhtrang = 0) AND (TblTre_1.Hovaten LIKE '%' + @Hotendem + '%') AND (TblTre_1.Tenthuonggoi LIKE '%' + @Tenthuonggoi + '%') AND  "
 + " 						  (TblTre_1.Noiohiennay LIKE '%' + @Noiohiennay + '%') AND (TblTre_1.Gioitinh LIKE '%' + @Gioitinh + '%') AND  "
 + " 						  (TblLop_1.Tenlop LIKE '%' + @Tenlop + '%') "
 + " ) AS Tbl2 ON  "
 + "                       Tbl1.NamtrehocId = Tbl2.NamtrehocId "
 + " WHERE     (Tbl1.Id IS NULL and Tbl2.NamhocId =?) "
 + " if(@Varvalue =1) -- Đã mua "
 + " SELECT     Tbl1.Id , Tbl1.Ten, Tbl1.Hotendem, Tbl1.Hovaten, Tbl1.Tenthuonggoi, Tbl1.Ngaysinh, Tbl1.Noiohiennay, Tbl1.Gioitinh, Tbl1.Sodt, Tbl1.UutienId,  "
 + "                       Tbl1.Hotenbo, Tbl1.Nghenghiepbo, Tbl1.Hotenme, Tbl1.Nghengheme, Tbl1.Ghichu, Tbl1.Tinhtrang, Tbl1.NamtrehocId, Tbl1.NamhocId "
 + " FROM         ( "
 + " 				SELECT      TblTre.Id, TblTre.Hotendem, TblTre.Ten, TblTre.Hovaten, TblTre.Tenthuonggoi, TblTre.Ngaysinh,  "
 + " 				  TblTre.Noiohiennay, TblTre.Gioitinh, TblTre.Sodt, TblTre.UutienId, TblTre.Hotenbo, TblTre.Nghenghiepbo,  "
 + " 				  TblTre.Hotenme, TblTre.Nghengheme, TblTre.Ghichu, TblTre.Tinhtrang, TblNamtrehoc.Id AS NamtrehocId,  "
 + " 				  TblPhieutienan.ThanghocId, TblNamtrehoc.NamhocId "
 + " 				FROM         TblTre INNER JOIN "
 + " 				  TblDm_Uutien ON TblDm_Uutien.Id = TblTre.UutienId INNER JOIN "
 + " 				  TblNamtrehoc ON TblTre.Id = TblNamtrehoc.TreId INNER JOIN "
 + " 				  TblPhieutienan ON TblNamtrehoc.Id = TblPhieutienan.NamtrehocId INNER JOIN "
 + " 				  TblLop ON TblNamtrehoc.LophocId = TblLop.Id "
 + " 				WHERE     (TblTre.Tinhtrang = 0) AND (TblTre.Hovaten LIKE '%' + @Hotendem + '%') AND (TblTre.Tenthuonggoi LIKE '%' + @Tenthuonggoi + '%') AND  "
 + " 				  (TblTre.Noiohiennay LIKE '%' + @Noiohiennay + '%') AND (TblTre.Gioitinh LIKE '%' + @Gioitinh + '%') AND  "
 + " 				  (TblPhieutienan.ThanghocId = ?) AND (TblLop.Tenlop LIKE '%' + @Tenlop + '%') "
 + " ) AS Tbl1 LEFT OUTER JOIN "
 + " (  "
 + " SELECT      TblTre_1.Id, TblTre_1.Hotendem, TblTre_1.Ten, TblTre_1.Hovaten, TblTre_1.Tenthuonggoi, TblTre_1.Ngaysinh,  "
 + "                       TblTre_1.Noiohiennay, TblTre_1.Gioitinh, TblTre_1.Sodt, TblTre_1.UutienId, TblTre_1.Hotenbo, TblTre_1.Nghenghiepbo, TblTre_1.Hotenme,  "
 + "                       TblTre_1.Nghengheme, TblTre_1.Ghichu, TblTre_1.Tinhtrang, TblNamtrehoc_1.Id AS NamtrehocId, TblNamtrehoc_1.NamhocId "
 + " FROM         TblTre AS TblTre_1 INNER JOIN "
 + "                       TblDm_Uutien AS TblDm_Uutien_1 ON TblDm_Uutien_1.Id = TblTre_1.UutienId INNER JOIN "
 + "                       TblNamtrehoc AS TblNamtrehoc_1 ON TblTre_1.Id = TblNamtrehoc_1.TreId INNER JOIN "
 + "                       TblLop AS TblLop_1 ON TblNamtrehoc_1.LophocId = TblLop_1.Id "
 + " WHERE     (TblTre_1.Tinhtrang = 0) AND (TblTre_1.Hovaten LIKE '%' + @Hotendem + '%') AND (TblTre_1.Tenthuonggoi LIKE '%' + @Tenthuonggoi + '%') AND  "
 + "                       (TblTre_1.Noiohiennay LIKE '%' + @Noiohiennay + '%') AND (TblTre_1.Gioitinh LIKE '%' + @Gioitinh + '%') AND  "
 + "                       (TblLop_1.Tenlop LIKE '%' + @Tenlop + '%') "
 + " ) AS Tbl2 ON Tbl1.NamtrehocId = Tbl2.NamtrehocId "
 + " where (Tbl1.NamhocId =?) "
 + " if(@Varvalue =2) -- Tất cả "
 + " SELECT     Tbl2.Hotendem, Tbl2.Ten, Tbl2.Hovaten, Tbl2.Tenthuonggoi, Tbl2.Ngaysinh, Tbl2.Noiohiennay, Tbl2.Gioitinh, Tbl2.Sodt, Tbl2.UutienId, Tbl2.Hotenbo,  "
 + "                       Tbl2.Nghenghiepbo, Tbl2.Hotenme, Tbl2.Nghengheme, Tbl2.Ghichu, Tbl2.Tinhtrang, Tbl2.NamtrehocId, Tbl2.Id, Tbl2.NamhocId "
 + " FROM         ( "
 + " SELECT      TblTre.Id, TblTre.Hotendem, TblTre.Ten, TblTre.Hovaten, TblTre.Tenthuonggoi, TblTre.Ngaysinh,  "
 + "                       TblTre.Noiohiennay, TblTre.Gioitinh, TblTre.Sodt, TblTre.UutienId, TblTre.Hotenbo, TblTre.Nghenghiepbo,  "
 + "                       TblTre.Hotenme, TblTre.Nghengheme, TblTre.Ghichu, TblTre.Tinhtrang, TblNamtrehoc.Id AS NamtrehocId,  "
 + "                       TblPhieutienan.ThanghocId, TblNamtrehoc.NamhocId "
 + " FROM         TblTre INNER JOIN "
 + "                       TblDm_Uutien ON TblDm_Uutien.Id = TblTre.UutienId INNER JOIN "
 + "                       TblNamtrehoc ON TblTre.Id = TblNamtrehoc.TreId INNER JOIN "
 + "                       TblPhieutienan ON TblNamtrehoc.Id = TblPhieutienan.NamtrehocId INNER JOIN "
 + "                       TblLop ON TblNamtrehoc.LophocId = TblLop.Id "
 + " WHERE     (TblTre.Tinhtrang = 0) AND (TblTre.Hovaten LIKE '%' + @Hotendem + '%') AND (TblTre.Tenthuonggoi LIKE '%' + @Tenthuonggoi + '%') AND  "
 + "                       (TblTre.Noiohiennay LIKE '%' + @Noiohiennay + '%') AND (TblTre.Gioitinh LIKE '%' + @Gioitinh + '%') AND  "
 + "                       (TblPhieutienan.ThanghocId = ?) AND (TblLop.Tenlop LIKE '%' + @Tenlop + '%') "
 + " ) AS Tbl1 RIGHT OUTER JOIN "
 + "  ( "
 + " SELECT      TblTre_1.Id, TblTre_1.Hotendem, TblTre_1.Ten, TblTre_1.Hovaten, TblTre_1.Tenthuonggoi, TblTre_1.Ngaysinh,  "
 + "                       TblTre_1.Noiohiennay, TblTre_1.Gioitinh, TblTre_1.Sodt, TblTre_1.UutienId, TblTre_1.Hotenbo, TblTre_1.Nghenghiepbo, TblTre_1.Hotenme,  "
 + "                       TblTre_1.Nghengheme, TblTre_1.Ghichu, TblTre_1.Tinhtrang, TblNamtrehoc_1.Id AS NamtrehocId, TblNamtrehoc_1.NamhocId "
 + " FROM         TblTre AS TblTre_1 INNER JOIN "
 + "                       TblDm_Uutien AS TblDm_Uutien_1 ON TblDm_Uutien_1.Id = TblTre_1.UutienId INNER JOIN "
 + "                       TblNamtrehoc AS TblNamtrehoc_1 ON TblTre_1.Id = TblNamtrehoc_1.TreId INNER JOIN "
 + "                       TblLop AS TblLop_1 ON TblNamtrehoc_1.LophocId = TblLop_1.Id "
 + " WHERE     (TblTre_1.Tinhtrang = 0) AND (TblTre_1.Hovaten LIKE '%' + @Hotendem + '%') AND (TblTre_1.Tenthuonggoi LIKE '%' + @Tenthuonggoi + '%') AND  "
 + "                       (TblTre_1.Noiohiennay LIKE '%' + @Noiohiennay + '%') AND (TblTre_1.Gioitinh LIKE '%' + @Gioitinh + '%') AND  "
 + "                       (TblLop_1.Tenlop LIKE '%' + @Tenlop + '') "
 + " ) AS Tbl2 ON Tbl1.NamtrehocId = Tbl2.NamtrehocId where (Tbl2.NamhocId =?) "
 + " else "
 + " if(@Varvalue =0) -- Chưa mua // la combotrangthai "
 + " SELECT     Tbl2.Hotendem, Tbl2.Ten, Tbl2.Hovaten, Tbl2.Tenthuonggoi, Tbl2.Ngaysinh, Tbl2.Noiohiennay, Tbl2.Gioitinh, Tbl2.Sodt, Tbl2.UutienId, Tbl2.Hotenbo,  "
 + "                       Tbl2.Nghenghiepbo, Tbl2.Hotenme, Tbl2.Nghengheme, Tbl2.Ghichu, Tbl2.Tinhtrang, Tbl2.NamtrehocId, Tbl2.Id, Tbl2.NamhocId "
 + " FROM         ( "
 + " SELECT      TblTre.Id, TblTre.Hotendem, TblTre.Ten, TblTre.Hovaten, TblTre.Tenthuonggoi, TblTre.Ngaysinh,  "
 + "                       TblTre.Noiohiennay, TblTre.Gioitinh, TblTre.Sodt, TblTre.UutienId, TblTre.Hotenbo, TblTre.Nghenghiepbo,  "
 + "                       TblTre.Hotenme, TblTre.Nghengheme, TblTre.Ghichu, TblTre.Tinhtrang, TblNamtrehoc.Id AS NamtrehocId,  "
 + "                       TblPhieutienan.ThanghocId, TblNamtrehoc.NamhocId "
 + " FROM         TblTre INNER JOIN "
 + "                       TblDm_Uutien ON TblDm_Uutien.Id = TblTre.UutienId INNER JOIN "
 + "                       TblNamtrehoc ON TblTre.Id = TblNamtrehoc.TreId INNER JOIN "
 + "                       TblPhieutienan ON TblNamtrehoc.Id = TblPhieutienan.NamtrehocId INNER JOIN "
 + "                       TblLop ON TblNamtrehoc.LophocId = TblLop.Id "
 + " WHERE     (TblTre.Tinhtrang = 0) AND (TblTre.Hovaten LIKE '%' + @Hotendem + '%') AND (TblTre.Tenthuonggoi LIKE '%' + @Tenthuonggoi + '%') AND  "
 + "                       (TblTre.Noiohiennay LIKE '%' + @Noiohiennay + '%') AND (TblTre.Gioitinh LIKE '%' + @Gioitinh + '%') AND (TblLop.Tenlop = @Tenlop) AND  "
 + "                       (TblPhieutienan.ThanghocId = ?) "
 + " )  "
 + "                       AS Tbl1 RIGHT OUTER JOIN "
 + " ( "
 + " SELECT      TblTre_1.Id, TblTre_1.Hotendem, TblTre_1.Ten, TblTre_1.Hovaten, TblTre_1.Tenthuonggoi, TblTre_1.Ngaysinh,  "
 + "                       TblTre_1.Noiohiennay, TblTre_1.Gioitinh, TblTre_1.Sodt, TblTre_1.UutienId, TblTre_1.Hotenbo, TblTre_1.Nghenghiepbo, TblTre_1.Hotenme,  "
 + "                       TblTre_1.Nghengheme, TblTre_1.Ghichu, TblTre_1.Tinhtrang, TblNamtrehoc_1.Id AS NamtrehocId, TblNamtrehoc_1.NamhocId "
 + " FROM         TblTre AS TblTre_1 INNER JOIN "
 + "                       TblDm_Uutien AS TblDm_Uutien_1 ON TblDm_Uutien_1.Id = TblTre_1.UutienId INNER JOIN "
 + "                       TblNamtrehoc AS TblNamtrehoc_1 ON TblTre_1.Id = TblNamtrehoc_1.TreId INNER JOIN "
 + "                       TblLop AS TblLop_1 ON TblNamtrehoc_1.LophocId = TblLop_1.Id "
 + " WHERE     (TblTre_1.Tinhtrang = 0) AND (TblTre_1.Hovaten LIKE '%' + @Hotendem + '%') AND (TblTre_1.Tenthuonggoi LIKE '%' + @Tenthuonggoi + '%') AND  "
 + "                       (TblTre_1.Noiohiennay LIKE '%' + @Noiohiennay + '%') AND (TblTre_1.Gioitinh LIKE '%' + @Gioitinh + '%') AND (TblLop_1.Tenlop = @Tenlop) "
 + " ) AS Tbl2 ON  "
 + "                       Tbl1.NamtrehocId = Tbl2.NamtrehocId "
 + " WHERE     (Tbl1.Id IS NULL and Tbl2.NamhocId =?) "
 + " if(@Varvalue =1) -- Đã mua "
 + " SELECT     Tbl1.Id , Tbl1.Ten, Tbl1.Hotendem, Tbl1.Hovaten, Tbl1.Tenthuonggoi, Tbl1.Ngaysinh, Tbl1.Noiohiennay, Tbl1.Gioitinh, Tbl1.Sodt, Tbl1.UutienId,  "
 + "                       Tbl1.Hotenbo, Tbl1.Nghenghiepbo, Tbl1.Hotenme, Tbl1.Nghengheme, Tbl1.Ghichu, Tbl1.Tinhtrang, Tbl1.NamtrehocId, Tbl1.NamhocId "
 + " FROM         ( "
 + " SELECT      TblTre.Id, TblTre.Hotendem, TblTre.Ten, TblTre.Hovaten, TblTre.Tenthuonggoi, TblTre.Ngaysinh,  "
 + "                       TblTre.Noiohiennay, TblTre.Gioitinh, TblTre.Sodt, TblTre.UutienId, TblTre.Hotenbo, TblTre.Nghenghiepbo,  "
 + "                       TblTre.Hotenme, TblTre.Nghengheme, TblTre.Ghichu, TblTre.Tinhtrang, TblNamtrehoc.Id AS NamtrehocId,  "
 + "                       TblPhieutienan.ThanghocId, TblNamtrehoc.NamhocId "
 + " FROM         TblTre INNER JOIN "
 + "                       TblDm_Uutien ON TblDm_Uutien.Id = TblTre.UutienId INNER JOIN "
 + "                       TblNamtrehoc ON TblTre.Id = TblNamtrehoc.TreId INNER JOIN "
 + "                       TblPhieutienan ON TblNamtrehoc.Id = TblPhieutienan.NamtrehocId INNER JOIN "
 + "                       TblLop ON TblNamtrehoc.LophocId = TblLop.Id "
 + " WHERE     (TblTre.Tinhtrang = 0) AND (TblTre.Hovaten LIKE '%' + @Hotendem + '%') AND (TblTre.Tenthuonggoi LIKE '%' + @Tenthuonggoi + '%') AND  "
 + "                       (TblTre.Noiohiennay LIKE '%' + @Noiohiennay + '%') AND (TblTre.Gioitinh LIKE '%' + @Gioitinh + '%') AND  "
 + "                       (TblPhieutienan.ThanghocId = ?) AND (TblLop.Tenlop = @Tenlop) "
 + " ) AS Tbl1 LEFT OUTER JOIN "
 + "                           ( "
 + " SELECT      TblTre_1.Id, TblTre_1.Hotendem, TblTre_1.Ten, TblTre_1.Hovaten, TblTre_1.Tenthuonggoi, TblTre_1.Ngaysinh,  "
 + "                       TblTre_1.Noiohiennay, TblTre_1.Gioitinh, TblTre_1.Sodt, TblTre_1.UutienId, TblTre_1.Hotenbo, TblTre_1.Nghenghiepbo, TblTre_1.Hotenme,  "
 + "                       TblTre_1.Nghengheme, TblTre_1.Ghichu, TblTre_1.Tinhtrang, TblNamtrehoc_1.Id AS NamtrehocId, TblNamtrehoc_1.NamhocId "
 + " FROM         TblTre AS TblTre_1 INNER JOIN "
 + "                       TblDm_Uutien AS TblDm_Uutien_1 ON TblDm_Uutien_1.Id = TblTre_1.UutienId INNER JOIN "
 + "                       TblNamtrehoc AS TblNamtrehoc_1 ON TblTre_1.Id = TblNamtrehoc_1.TreId INNER JOIN "
 + "                       TblLop AS TblLop_1 ON TblNamtrehoc_1.LophocId = TblLop_1.Id "
 + " WHERE     (TblTre_1.Tinhtrang = 0) AND (TblTre_1.Hovaten LIKE '%' + @Hotendem + '%') AND (TblTre_1.Tenthuonggoi LIKE '%' + @Tenthuonggoi + '%') AND  "
 + "                       (TblTre_1.Noiohiennay LIKE '%' + @Noiohiennay + '%') AND (TblTre_1.Gioitinh LIKE '%' + @Gioitinh + '%') AND (TblLop_1.Tenlop = @Tenlop) "
 + " ) AS Tbl2 ON Tbl1.NamtrehocId = Tbl2.NamtrehocId where (Tbl1.NamhocId =?) "
 + " if(@Varvalue =2) -- Tất cả "
 + " SELECT     Tbl2.Hotendem, Tbl2.Ten, Tbl2.Hovaten, Tbl2.Tenthuonggoi, Tbl2.Ngaysinh, Tbl2.Noiohiennay, Tbl2.Gioitinh, Tbl2.Sodt, Tbl2.UutienId, Tbl2.Hotenbo,  "
 + "                       Tbl2.Nghenghiepbo, Tbl2.Hotenme, Tbl2.Nghengheme, Tbl2.Ghichu, Tbl2.Tinhtrang, Tbl2.NamtrehocId, Tbl2.Id, Tbl2.NamhocId "
 + " FROM         ( "
 + " SELECT      TblTre.Id, TblTre.Hotendem, TblTre.Ten, TblTre.Hovaten, TblTre.Tenthuonggoi, TblTre.Ngaysinh,  "
 + "                       TblTre.Noiohiennay, TblTre.Gioitinh, TblTre.Sodt, TblTre.UutienId, TblTre.Hotenbo, TblTre.Nghenghiepbo,  "
 + "                       TblTre.Hotenme, TblTre.Nghengheme, TblTre.Ghichu, TblTre.Tinhtrang, TblNamtrehoc.Id AS NamtrehocId,  "
 + "                       TblPhieutienan.ThanghocId, TblNamtrehoc.NamhocId "
 + " FROM         TblTre INNER JOIN "
 + "                       TblDm_Uutien ON TblDm_Uutien.Id = TblTre.UutienId INNER JOIN "
 + "                       TblNamtrehoc ON TblTre.Id = TblNamtrehoc.TreId INNER JOIN "
 + "                       TblPhieutienan ON TblNamtrehoc.Id = TblPhieutienan.NamtrehocId INNER JOIN "
 + "                       TblLop ON TblNamtrehoc.LophocId = TblLop.Id "
 + " WHERE     (TblTre.Tinhtrang = 0) AND (TblTre.Hovaten LIKE '%' + @Hotendem + '%') AND (TblTre.Tenthuonggoi LIKE '%' + @Tenthuonggoi + '%') AND  "
 + "                       (TblTre.Noiohiennay LIKE '%' + @Noiohiennay + '%') AND (TblTre.Gioitinh LIKE '%' + @Gioitinh + '%') AND (TblLop.Tenlop = @Tenlop) AND  "
 + "                       (TblPhieutienan.ThanghocId = ?) "
 + " ) AS Tbl1 RIGHT OUTER JOIN "
 + "                           ( "
 + " SELECT      TblTre_1.Id, TblTre_1.Hotendem, TblTre_1.Ten, TblTre_1.Hovaten, TblTre_1.Tenthuonggoi, TblTre_1.Ngaysinh,  "
 + "                       TblTre_1.Noiohiennay, TblTre_1.Gioitinh, TblTre_1.Sodt, TblTre_1.UutienId, TblTre_1.Hotenbo, TblTre_1.Nghenghiepbo, TblTre_1.Hotenme,  "
 + "                       TblTre_1.Nghengheme, TblTre_1.Ghichu, TblTre_1.Tinhtrang, TblNamtrehoc_1.Id AS NamtrehocId, TblNamtrehoc_1.NamhocId "
 + " FROM         TblTre AS TblTre_1 INNER JOIN "
 + "                       TblDm_Uutien AS TblDm_Uutien_1 ON TblDm_Uutien_1.Id = TblTre_1.UutienId INNER JOIN "
 + "                       TblNamtrehoc AS TblNamtrehoc_1 ON TblTre_1.Id = TblNamtrehoc_1.TreId INNER JOIN "
 + "                       TblLop AS TblLop_1 ON TblNamtrehoc_1.LophocId = TblLop_1.Id "
 + " WHERE     (TblTre_1.Tinhtrang = 0) AND (TblTre_1.Hovaten LIKE '%' + @Hotendem + '%') AND (TblTre_1.Tenthuonggoi LIKE '%' + @Tenthuonggoi + '%') AND  "
 + "                       (TblTre_1.Noiohiennay LIKE '%' + @Noiohiennay + '%') AND (TblTre_1.Gioitinh LIKE '%' + @Gioitinh + '%') AND (TblLop_1.Tenlop = @Tenlop) "
 + " ) AS Tbl2 ON Tbl1.NamtrehocId = Tbl2.NamtrehocId "
 + " where (Tbl2.NamhocId =?) ";
        public static string SP_PHIEUTIENAN_SELECTBYLOPHOCIDNAMHOCIDTHANGHOCIDNAMTREHOCIDSOBIENLAI = "SELECT     TblPhieutienan.Id, TblPhieutienan.Sobienlai, TblPhieutienan.NamtrehocId, TblPhieutienan.Ngaymua, TblPhieutienan.ThanghocId, "
 + "                       TblPhieutienan.Tongsophieumua, TblPhieutienan.Tongsophieudoi, TblPhieutienan.Dongia, TblPhieutienan.Ghichu,  "
 + "                       TblNamtrehoc.NamhocId, TblNamtrehoc.LophocId "
 + " FROM         TblPhieutienan INNER JOIN "
 + "                       TblNamtrehoc ON TblPhieutienan.NamtrehocId = TblNamtrehoc.Id "
 + " WHERE     (TblNamtrehoc.NamhocId = @NamhocId) AND (TblNamtrehoc.LophocId = @LophocId) AND (TblPhieutienan.NamtrehocId = @NamtrehocId)  "
 + "                       AND (TblPhieutienan.ThanghocId = @ThanghocId) OR "
 + "                       (TblPhieutienan.Sobienlai = @Sobienlai) ";

        public static string SP_REPORT_SOTONKHO = "	"
 + "     SELECT      "
 + "             (SELECT Tenthucan FROM TblThucpham_thucan WHERE (Id = vwTP.Thucpham_ThucanId) OR (Id = vwKho.Thucpham_ThucanId)) AS Tenthucan,  "
 + " 			(SELECT  TblDm_Donvitinh.Tendonvitinh FROM TblThucpham_thucan AS tp1 INNER JOIN TblDm_Donvitinh ON tp1.DonvitinhId = TblDm_Donvitinh.Id  WHERE (tp1.Id = vwTP.Thucpham_ThucanId) OR (tp1.Id = vwKho.Thucpham_ThucanId)) as Tendonvitinh, "
 + " 				vwKho.Soluong as SLTon, "
 + "                           (SELECT     TOP (1) PERCENT Dongia "
 + "                             FROM          vwNhaponDay AS nhap1 "
 + "                             WHERE      (CONVERT(nvarchar(10), NgayNX, 103) < CONVERT(nvarchar(10), @dateReport, 103)) AND (Thucpham_ThucanId = vwKho.Thucpham_ThucanId) "
 + "                             ORDER BY NgayNX DESC) AS GiaTon,  "
 + " 			tblNhap.Soluong AS SLNhap, tblNhap.Dongia AS GiaNhap, tblXuat.Soluong AS SLXuat, tblXuat.Dongia AS GiaXuat "
 + " FROM     (SELECT NgayNX, Thucpham_ThucanId FROM vwReportThucpham WHERE (CONVERT(nvarchar(10), NgayNX, 103) = CONVERT(nvarchar(10), @dateReport, 103))) AS vwTP LEFT OUTER JOIN "
 + "          (SELECT Tenthucan, Soluong, Tendonvitinh, Dongia, Thanhtien, NgayNX, Trangthai, Thucpham_ThucanId FROM vwXuatonDay WHERE (CONVERT(nvarchar(10), NgayNX, 103) = CONVERT(nvarchar(10), @dateReport, 103))) AS tblXuat ON vwTP.Thucpham_ThucanId = tblXuat.Thucpham_ThucanId LEFT OUTER JOIN "
 + "          (SELECT Tenthucan, Soluong, Tendonvitinh, Dongia, Thanhtien, NgayNX, Trangthai, Thucpham_ThucanId FROM vwNhaponDay WHERE (CONVERT(nvarchar(10), NgayNX, 103) = CONVERT(nvarchar(10), @dateReport, 103))) AS tblNhap ON vwTP.Thucpham_ThucanId = tblNhap.Thucpham_ThucanId FULL OUTER JOIN "
 + "          (SELECT Thucpham_ThucanId, SUM(Soluong) AS Soluong FROM vwKhobyDay WHERE (CONVERT(nvarchar(10), NgayNX, 103) < CONVERT(nvarchar(10), @dateReport, 103)) GROUP BY Thucpham_ThucanId HAVING  (SUM(Soluong) > 0)) AS vwKho ON vwTP.Thucpham_ThucanId = vwKho.Thucpham_ThucanId "
 + " ORDER BY Tenthucan ";
        public static string SP_TBLDM_CHISOKENHSUCKHOEDOTUOI_DEL = "delete from TblDm_Chisokenhsuckhoedotuoi "
 + " where (Id =@Id) ";
        public static string SP_TBLDM_CHISOKENHSUCKHOEDOTUOI_EDIT = "update TblDm_Chisokenhsuckhoedotuoi "
 + " set Tenkenh ='@Tenkenh',Viettat ='@Viettat', Chisocn =@Chisocn  "
 + " where (Id =@Id) ";
        public static string SP_TBLDM_CHISOKENHSUCKHOEDOTUOI_INSERT = "insert into TblDm_Chisokenhsuckhoedotuoi(Tenkenh,viettat,chisocn) values('@Tenkenh','@Viettat' ,@Chisocn )";
        public static string SP_TBLDM_CHISOKENHSUCKHOEDOTUOI_SELECTALL = "select * from TblDm_Chisokenhsuckhoedotuoi ";
        public static string SP_TBLDM_CHISOKENHSUCKHOEDOTUOI_SELECTBYCHISOCN = "SELECT     Id, Viettat, Tenkenh"
 + " FROM         TblDm_Chisokenhsuckhoedotuoi "
 + " WHERE     (Chisocn = @Chisocn) ";
        public static string SP_TBLDMSUCKHOEDOTUOI_EDIT = "update TblDm_Suckhoethangtuoi"
 + "           set "
 + "          Giatri1 =  '@Giatri1', "
 + "           Giatri2 = '@Giatri2' "
 + " where (Id =@Id) ";
        public static string SP_TBLDMSUCKHOEDOTUOI_INSERT = "INSERT INTO TblDm_Suckhoethangtuoi"
 + "            (KenhId "
 + "            ,Thangtuoi "
 + "            ,Giatri1 "
 + "            ,Giatri2 "
 + "            ,Gioitinh "
 + "            ,Chiso) "
 + "      VALUES ('@KenhId', "
 + "            '@Thangtuoi', "
 + "            '@Giatri1', "
 + "            '@Giatri2', "
 + "            '@Gioitinh', "
 + "            '@Chiso') ";

        public static string SP_TBLTREKIEMTRASUCKHOE_SELECTBY = "(SELECT   top 1  Viettat"
 + "                             FROM          View_Dmsuckhoedotuoi AS View_Dmsuckhoedotuoi_1 "
 + "                             WHERE      (ISNULL(sp_tblTrekiemtrasuckhoe.Cannang, 0) >= Giatri1) AND (ISNULL(sp_tblTrekiemtrasuckhoe.Cannang, 0) <= Giatri2) AND  "
 + "                                                    (View_Namtrehoc.Gioitinh = Gioitinh) AND (Chiso = N'Cân nặng') AND ((DATEPART(year, GETDATE()) - DATEPART(year,  "
 + "                                                    View_Namtrehoc.Ngaysinh)) * 12 + DATEPART(month, GETDATE()) - DATEPART(month, View_Namtrehoc.Ngaysinh) = Thangtuoi))  "
 + "                       AS KqCannang, sp_tblTrekiemtrasuckhoe.Danhgia, sp_tblTrekiemtrasuckhoe.Ngaykiemtra "
 + " FROM         (SELECT     NamtrehocId, LophocId, NamhocId, Hovaten, Tenthuonggoi, Gioitinh, Ngaysinh "
 + "                        FROM          Vw_Tre_namtrehoc "
 + "                        WHERE      (LophocId = @LophocId) AND (NamhocId = ?)) AS View_Namtrehoc FULL OUTER JOIN "
 + "                           (SELECT     TblTrekiemtrasuckhoe.Id, Vw_Tre_namtrehoc_1.NamtrehocId, Vw_Tre_namtrehoc_1.LophocId, Vw_Tre_namtrehoc_1.NamhocId,  "
 + "                                                    Vw_Tre_namtrehoc_1.Hovaten, Vw_Tre_namtrehoc_1.Tenthuonggoi, TblTrekiemtrasuckhoe.ThanghocId,  "
 + "                                                    TblTrekiemtrasuckhoe.Ngaykiemtra, ISNULL(TblTrekiemtrasuckhoe.Chieucao, 0) AS Chieucao,  "
 + "                                                    ISNULL(TblTrekiemtrasuckhoe.Cannang, 0) AS Cannang, TblTrekiemtrasuckhoe.Danhgia "
 + "                             FROM          Vw_Tre_namtrehoc AS Vw_Tre_namtrehoc_1 INNER JOIN "
 + "                                                    TblTrekiemtrasuckhoe ON Vw_Tre_namtrehoc_1.NamtrehocId = TblTrekiemtrasuckhoe.NamtrehocId "
 + "                             WHERE      (Vw_Tre_namtrehoc_1.LophocId = @LophocId) AND (Vw_Tre_namtrehoc_1.NamhocId = ?) AND  "
 + "                                                    (TblTrekiemtrasuckhoe.ThanghocId = ?)) AS sp_tblTrekiemtrasuckhoe ON  "
 + "                       View_Namtrehoc.NamtrehocId = sp_tblTrekiemtrasuckhoe.NamtrehocId "
 + " else "
 + " 		SELECT     sp_tblTrekiemtrasuckhoe.Id, View_Namtrehoc.NamtrehocId, View_Namtrehoc.LophocId, View_Namtrehoc.NamhocId, View_Namtrehoc.Hovaten,  "
 + "                       View_Namtrehoc.Gioitinh, sp_tblTrekiemtrasuckhoe.ThanghocId, ISNULL(sp_tblTrekiemtrasuckhoe.Chieucao, 0) AS Chieucao, "
 + "                           (SELECT   top 1  Viettat "
 + "                             FROM          View_Dmsuckhoedotuoi AS View_Dmsuckhoedotuoi_1 "
 + "                             WHERE      (ISNULL(sp_tblTrekiemtrasuckhoe.Chieucao, 0)*100 >= Giatri1) AND (ISNULL(sp_tblTrekiemtrasuckhoe.Chieucao, 0)*100 <= Giatri2) AND  "
 + "                                                    (View_Namtrehoc.Gioitinh = Gioitinh) AND (Chiso = N'Chiều cao') AND ((DATEPART(year, GETDATE()) - DATEPART(year,  "
 + "                                                    View_Namtrehoc.Ngaysinh)) * 12 + DATEPART(month, GETDATE()) - DATEPART(month, View_Namtrehoc.Ngaysinh) = Thangtuoi))  "
 + "                       AS KqChieucao,  "
 + "                       ISNULL(sp_tblTrekiemtrasuckhoe.Cannang, 0) AS Cannang, "
 + "                           (SELECT  top 1   Viettat "
 + "                             FROM          View_Dmsuckhoedotuoi AS View_Dmsuckhoedotuoi_1 "
 + "                             WHERE      (ISNULL(sp_tblTrekiemtrasuckhoe.Cannang, 0) >= Giatri1) AND (ISNULL(sp_tblTrekiemtrasuckhoe.Cannang, 0) <= Giatri2) AND  "
 + "                                                    (View_Namtrehoc.Gioitinh = Gioitinh) AND (Chiso = N'Cân nặng') AND ((DATEPART(year, GETDATE()) - DATEPART(year,  "
 + "                                                    View_Namtrehoc.Ngaysinh)) * 12 + DATEPART(month, GETDATE()) - DATEPART(month, View_Namtrehoc.Ngaysinh) = Thangtuoi))  "
 + "                       AS KqCannang,  "
 + "                       sp_tblTrekiemtrasuckhoe.Danhgia, sp_tblTrekiemtrasuckhoe.Ngaykiemtra "
 + " FROM         (SELECT     NamtrehocId, LophocId, NamhocId, Hovaten, Tenthuonggoi, Gioitinh, Ngaysinh "
 + "                        FROM          Vw_Tre_namtrehoc "
 + "                        WHERE      (NamhocId = ?)) AS View_Namtrehoc FULL OUTER JOIN "
 + "                           (SELECT     TblTrekiemtrasuckhoe.Id, Vw_Tre_namtrehoc_1.NamtrehocId, Vw_Tre_namtrehoc_1.LophocId, Vw_Tre_namtrehoc_1.NamhocId,  "
 + "                                                    Vw_Tre_namtrehoc_1.Hovaten, Vw_Tre_namtrehoc_1.Tenthuonggoi, TblTrekiemtrasuckhoe.ThanghocId,  "
 + "                                                    TblTrekiemtrasuckhoe.Ngaykiemtra, ISNULL(TblTrekiemtrasuckhoe.Chieucao, 0) AS Chieucao,  "
 + "                                                    ISNULL(TblTrekiemtrasuckhoe.Cannang, 0) AS Cannang, TblTrekiemtrasuckhoe.Danhgia "
 + "                             FROM          Vw_Tre_namtrehoc AS Vw_Tre_namtrehoc_1 INNER JOIN "
 + "                                                    TblTrekiemtrasuckhoe ON Vw_Tre_namtrehoc_1.NamtrehocId = TblTrekiemtrasuckhoe.NamtrehocId "
 + "                             WHERE      (Vw_Tre_namtrehoc_1.NamhocId = ?) AND (TblTrekiemtrasuckhoe.ThanghocId = ?))  "
 + "                       AS sp_tblTrekiemtrasuckhoe ON View_Namtrehoc.NamtrehocId = sp_tblTrekiemtrasuckhoe.NamtrehocId ";
        public static string SP_THUCPHAMTHEOBUA_SELECTALL = "SELECT     ISNULL(DV.Thucpham_ThucanId, TV.Thucpham_ThucanId) AS Thucpham_ThucanId, ISNULL(DV.ListTenthucan, TV.ListTenthucan) AS ListTenthucan, "
 + "                     ISNULL(ISNULL(DV.Calo, TV.Calo), 0) AS Calo, ISNULL(DV.Tphh_Protid, 0) AS DV_Protid, ISNULL(TV.Tphh_Protid, 0) AS TV_Protid,  "
 + "                     ISNULL(DV.Tphh_Lipid, 0) AS DV_Lipid, ISNULL(TV.Tphh_Lipid, 0) AS TV_Lipid, ISNULL(DV.Tphh_GlucId, TV.Tphh_GlucId) AS GlucId,  "
 + "                     ISNULL(DV.Soluong, TV.Soluong) AS Soluong, ISNULL(DV.ListTendonvitinh, TV.ListTendonvitinh) AS ListTendonvitinh, ISNULL(ISNULL(DV.Tylequydoi,  "
 + "                     TV.Tylequydoi), 0) AS Tylequydoi, ISNULL(ISNULL(DV.Tylethai, TV.Tylethai), 0) AS Tylethai "
 + " FROM         (SELECT     TblSum.Thucpham_ThucanId, TblSum.ListTenthucan, TblSum.Soluong, TblSum.ListTendonvitinh, TblThucpham_thucan_1.Tylequydoi, "
 + "                                              TblThucpham_thucan AS TblThucpham_thucan_1 ON TblSum.Thucpham_ThucanId = TblThucpham_thucan_1.Id INNER JOIN"
 + "                                               TblThanhphanhoahoc ON TblThucpham_thucan_1.Id = TblThanhphanhoahoc.IdThucpham_thucan "
 + "                        WHERE      (TblThucpham_thucan_1.Nguondongvat = 1)) AS DV FULL OUTER JOIN "
 + "                           (SELECT     TblSum_1.Thucpham_ThucanId, TblSum_1.ListTenthucan, TblSum_1.Soluong, TblSum_1.ListTendonvitinh,  "
 + "                                                    TblThucpham_thucan_1.Tylequydoi, TblThucpham_thucan_1.Tylethai, TblThanhphanhoahoc_1.Tphh_Protid,  "
 + "                                                    TblThanhphanhoahoc_1.Tphh_Lipid, TblThanhphanhoahoc_1.Tphh_GlucId, TblThucpham_thucan_1.Calo "
 + "                             FROM          (SELECT     Thucphamtheobua_1.Thucpham_ThucanId, TblThucpham_thucan_2.Tenthucan AS ListTenthucan,  "
 + "                                                                            SUM(Thucphamtheobua_1.Soluong) AS Soluong, TblDm_Donvitinh_1.Tendonvitinh AS ListTendonvitinh "
 + "                                                     FROM          Thucphamtheobua AS Thucphamtheobua_1 INNER JOIN "
 + "                                                                            TblThucpham_thucan AS TblThucpham_thucan_2 ON  "
 + "                                                                            Thucphamtheobua_1.Thucpham_ThucanId = TblThucpham_thucan_2.Id INNER JOIN "
 + "                                                                            TblDm_Donvitinh AS TblDm_Donvitinh_1 ON TblThucpham_thucan_2.DonvitinhId = TblDm_Donvitinh_1.Id "
 + "                                                     WHERE      (Thucphamtheobua_1.Khoilop = @KhoilopId) AND (Thucphamtheobua_1.Ngay = @Ngay) "
 + "                                                     GROUP BY Thucphamtheobua_1.Thucpham_ThucanId, TblThucpham_thucan_2.Tenthucan, TblDm_Donvitinh_1.Tendonvitinh)  "
 + "                                                    AS TblSum_1 INNER JOIN "
 + "                                                    TblThucpham_thucan AS TblThucpham_thucan_1 ON TblSum_1.Thucpham_ThucanId = TblThucpham_thucan_1.Id INNER JOIN "
 + "                                                    TblThanhphanhoahoc AS TblThanhphanhoahoc_1 ON  "
 + "                                                    TblThucpham_thucan_1.Id = TblThanhphanhoahoc_1.IdThucpham_thucan "
 + "                             WHERE      (TblThucpham_thucan_1.Nguondongvat = 0)) AS TV ON DV.Thucpham_ThucanId = TV.Thucpham_ThucanId ";
        public static string SP_TIENANCHITIET_SELECTBYTHANGHOCIDNAMTREHOCID = "SELECT     Tongsobua * ISNULL(Giatien, 0) AS Tongtien"
 + " FROM         (SELECT     COUNT(TblDiemdanhtrean.Id) AS Tongsobua, TblGia.Giatien "
 + "                        FROM          TblDiemdanhtrean CROSS JOIN "
 + "                                               TblGia "
 + "                        WHERE      (TblDiemdanhtrean.Trangthai = 1) AND (TblDiemdanhtrean.ThanghocId = ?) AND  "
 + "                                               (TblDiemdanhtrean.NamtrehocId = @NamtrehocId) "
 + "                        GROUP BY TblGia.Giatien) AS Tbl ";
        public static string SP_USER_INSERT = "INSERT INTO [User](UserName, Password, FullName, Status) VALUES (@UserName, @Password, @FullName, @Status)";
        public static string SP_USER_UPDATE = "UPDATE [User] SET UserName = @UserName, Password = @Password, FullName = @FullName, Status = @Status WHERE UserID = @UserID";
        public static string SP_USER_CHANGEPASS = "UPDATE [User] SET Password = @Password WHERE UserName = @UserName";
        public static string SP_USER_SELECTONE = "SELECT * FROM [User] where userName=?";
        public static string SP_USER_SELECTALL = "SELECT * FROM [User]";
        public static string SP_USER_DELETE = "	DELETE FROM [User] WHERE UserID = @UserID";
        public static string SP_VWBAOAN_GETSUMALLBYDAY = "	" + "     select * from vwBaoan where Ngay=@dateBaoan ";
        public static string SP_VWPHIEUTIENAN_SELECTBYLOPHOC = "	" + " 	if(@LophocID<>0) "
 + " 		SELECT * FROM vwPhieutienan WHERE  LophocId = ? and ThanghocID=? "
 + " 	else "
 + " 		SELECT * FROM vwPhieutienan WHERE  ThanghocID=? "
;
        public static string SP_VWTHUCDON_GETBYDATE4REPORT = "	" + " 	SELECT     TblThucdon_monan.Id, TblThucdon_monan.KhoilopId, TblDm_Khoilop.Tenkhoilop, TblThucdon_monan.BuaantrongngayId,  "
 + "                       TblDm_Buaantrongngay.Tenbuaan, TblThucdon_monan.ThuvienmonanId, TblDm_Thuvienmonan.Tenmonan,  "
 + "                       TblThucdon_monan.Ngay "
 + " 	FROM         TblThucdon_monan INNER JOIN "
 + " 						  TblDm_Khoilop ON TblThucdon_monan.KhoilopId = TblDm_Khoilop.Id INNER JOIN "
 + " 						  TblDm_Thuvienmonan ON TblThucdon_monan.ThuvienmonanId = TblDm_Thuvienmonan.Id INNER JOIN "
 + " 						  TblDm_Buaantrongngay ON TblThucdon_monan.BuaantrongngayId = TblDm_Buaantrongngay.Id "
 + " 	WHERE  Convert(varchar(10), Ngay, 101) = Convert(varchar(10), @dateReport, 101) "
;
        public static string SP_VWTHUCDON_GETBYWEEK4REPORT = "	" + " 	SELECT     TblThucdon_monan.Id, TblThucdon_monan.KhoilopId, TblDm_Khoilop.Tenkhoilop, TblThucdon_monan.BuaantrongngayId,  "
 + "                       TblDm_Buaantrongngay.Tenbuaan, TblThucdon_monan.ThuvienmonanId, TblDm_Thuvienmonan.Tenmonan,  "
 + "                       TblThucdon_monan.Ngay "
 + " 	FROM         TblThucdon_monan INNER JOIN "
 + " 						  TblDm_Khoilop ON TblThucdon_monan.KhoilopId = TblDm_Khoilop.Id INNER JOIN "
 + " 						  TblDm_Thuvienmonan ON TblThucdon_monan.ThuvienmonanId = TblDm_Thuvienmonan.Id INNER JOIN "
 + " 						  TblDm_Buaantrongngay ON TblThucdon_monan.BuaantrongngayId = TblDm_Buaantrongngay.Id "
 + " 	WHERE  Ngay between  @startDate and @endDate "
;
        public static string SP_VWTHUTHEOTHANG_SELECTBYLOPHOC = "	declare @SQL nvarchar(1000)"
 + " 	set @SQL='SELECT  vwThutheothang.* FROM vwThutheothang WHERE ThanghocId = ' + convert(nvarchar(10),? )  "
 + " 	if(@LophocID!=0) "
 + " 		set @SQL = @SQL + ' and LophocId = ' + convert(nvarchar(10),@LophocID)  "
 + " 	set @SQL = @SQL + ' order by treid ' "
 + " 	print @SQL "
 + " 	exec(@SQL) ";
        public static string SP_VWTHUTHEOTHANG_SELECTBYNAMTREHOCID = "	SELECT  vwThutheothang.* FROM vwThutheothang WHERE ThanghocId = ? and NamtrehocID = @NamtrehocID"
 + " 	 order by treid  ";
        public static string SPROC_CLEAR_THUCDONMONAN_THUCPHAMDUKIEN_HOADONNHAPXUAT = "delete FROM  TblThucdon_monan;"
 + " delete FROM Thucphamtheobua; "
 + " delete FROM Thucphamtheobua; "
 + " delete FROM TblNhapxuathanghoa; "
 + " delete FROM TblHoadonnhapxuat; ";
        public static string SPROC_GIANHAPBYNGAYNXANDTHUCPHAMTHUCANID = "SELECT      TblNhapxuathanghoa.Thucpham_ThucanId, TblNhapxuathanghoa.Dongia, TblHoadonnhapxuat.NgayNX"
 + " FROM         TblNhapxuathanghoa INNER JOIN "
 + "                       TblHoadonnhapxuat ON TblNhapxuathanghoa.HoadonnhapxuatId = TblHoadonnhapxuat.Id "
 + " WHERE     (TblHoadonnhapxuat.Trangthai = -1) AND (TblHoadonnhapxuat.NgayNX <= @NgayNX) AND  "
 + "                       (TblNhapxuathanghoa.Thucpham_ThucanId = ?) "
 + " ORDER BY TblHoadonnhapxuat.Id DESC ";
        public static string SPROC_PHIEUTIENAN = "if(@LophocId =-1)"
 + " 	SELECT      TblTre.Id, TblTre.Hotendem, TblTre.Ten, TblTre.Hovaten, TblTre.Tenthuonggoi, TblTre.Ngaysinh,  "
 + "                       TblTre.Gioitinh, TblTre.Noiohiennay, TblTre.UutienId, TblTre.Sodt, TblTre.Tinhtrang, TblTre.Nghengheme,  "
 + "                       TblTre.Hotenme, TblTre.Nghenghiepbo, TblTre.Hotenbo, TblNamtrehoc.Id AS Expr1, TblTre.Ghichu,  "
 + "                       TblPhieutienan.ThanghocId "
 + " FROM         TblTre INNER JOIN "
 + "                       TblDm_Uutien ON TblDm_Uutien.Id = TblTre.UutienId INNER JOIN "
 + "                       TblNamtrehoc ON TblTre.Id = TblNamtrehoc.TreId INNER JOIN "
 + "                       TblPhieutienan ON TblNamtrehoc.Id = TblPhieutienan.NamtrehocId "
 + " WHERE     (TblTre.Tinhtrang = 0) "
 + "  AND (TblTre.Hovaten LIKE '%' + @Hotendem + '%') AND  "
 + "                       (TblTre.Tenthuonggoi LIKE '%' + @Tenthuonggoi + '%')  "
 + " AND (TblDm_Uutien.Tenuutien LIKE '%' + @UutienId + '%') AND  "
 + "                       (TblTre.Noiohiennay LIKE '%' + @Noiohiennay + '%') "
 + "  AND (TblTre.Gioitinh LIKE '%' + @Gioitinh + '%') AND  "
 + "                       (TblPhieutienan.ThanghocId = ?) "
 + " else "
 + " 	SELECT      TblTre.Id, TblTre.Hotendem, TblTre.Ten, TblTre.Hovaten, TblTre.Tenthuonggoi, TblTre.Ngaysinh,  "
 + "                       TblTre.Gioitinh, TblTre.Noiohiennay, TblTre.UutienId, TblTre.Sodt, TblTre.Tinhtrang, TblTre.Nghengheme,  "
 + "                       TblTre.Hotenme, TblTre.Nghenghiepbo, TblTre.Hotenbo, TblNamtrehoc.Id AS Expr1, TblTre.Ghichu,  "
 + "                       TblPhieutienan.ThanghocId "
 + " FROM         TblTre INNER JOIN "
 + "                       TblDm_Uutien ON TblDm_Uutien.Id = TblTre.UutienId INNER JOIN "
 + "                       TblNamtrehoc ON TblTre.Id = TblNamtrehoc.TreId INNER JOIN "
 + "                       TblPhieutienan ON TblNamtrehoc.Id = TblPhieutienan.NamtrehocId "
 + " WHERE     (TblNamtrehoc.LophocId = @LophocId) AND (TblTre.Tinhtrang = 0) "
 + "  AND (TblTre.Hovaten LIKE '%' + @Hotendem + '%') AND  "
 + "                       (TblTre.Tenthuonggoi LIKE '%' + @Tenthuonggoi + '%')  "
 + " AND (TblDm_Uutien.Tenuutien LIKE '%' + @UutienId + '%') AND  "
 + "                       (TblTre.Noiohiennay LIKE '%' + @Noiohiennay + '%') "
 + "  AND (TblTre.Gioitinh LIKE '%' + @Gioitinh + '%') AND  "
 + "                       (TblPhieutienan.ThanghocId = ?) ";
        public static string SPROC_PHIEUTIENAN_SELECTBYLOPHOC = "	SELECT      TblTre.Id, TblTre.Hotendem, TblTre.Ten, TblTre.Hovaten, TblTre.Tenthuonggoi, TblTre.Ngaysinh, "
 + "                       TblTre.Gioitinh, TblTre.Noiohiennay, TblTre.UutienId, TblTre.Sodt, TblTre.Tinhtrang, TblTre.Nghengheme,  "
 + "                       TblTre.Hotenme, TblTre.Nghenghiepbo, TblTre.Hotenbo, TblNamtrehoc.Id AS Expr1, TblTre.Ghichu,  "
 + "                       TblPhieutienan.ThanghocId "
 + " FROM         TblTre INNER JOIN "
 + "                       TblDm_Uutien ON TblDm_Uutien.Id = TblTre.UutienId INNER JOIN "
 + "                       TblNamtrehoc ON TblTre.Id = TblNamtrehoc.TreId INNER JOIN "
 + "                       TblPhieutienan ON TblNamtrehoc.Id = TblPhieutienan.NamtrehocId "
 + " WHERE     (TblNamtrehoc.LophocId = @LophocId) AND (TblTre.Tinhtrang = 0) "
 + "  AND (TblTre.Hovaten LIKE '%' + @Hotendem + '%') AND  "
 + "                       (TblTre.Tenthuonggoi LIKE '%' + @Tenthuonggoi + '%')  "
 + " AND (TblDm_Uutien.Tenuutien LIKE '%' + @UutienId + '%') AND  "
 + "                       (TblTre.Noiohiennay LIKE '%' + @Noiohiennay + '%') "
 + "  AND (TblTre.Gioitinh LIKE '%' + @Gioitinh + '%') AND  "
 + "                       (TblPhieutienan.ThanghocId = ?) ";
        public static string SPROC_SELECTALHOADONNXBYNGAY = "SELECT     NgayNX, Tongtien, Trangthai, Id"
 + " FROM         TblHoadonnhapxuat "
 + " WHERE     (NgayNX = @NgayNX) AND (Trangthai = 1) ";
        public static string SPROC_TBL_TONGHOPTHU_CHI = "	SELECT     TblThucpham_thucan.Tenthucan, TblNhapxuathanghoa.Soluong, TblDm_Donvitinh.Tendonvitinh, TblNhapxuathanghoa.Dongia, " +
" TblNhapxuathanghoa.Dongia * TblNhapxuathanghoa.Soluong as Thanhtien,   TblHoadonnhapxuat.NgayNX  " +
" FROM (TblDm_Donvitinh INNER JOIN TblThucpham_thucan ON TblDm_Donvitinh.Id = TblThucpham_thucan.DonvitinhId) INNER JOIN (TblHoadonnhapxuat INNER JOIN TblNhapxuathanghoa ON TblHoadonnhapxuat.Id = TblNhapxuathanghoa.HoadonnhapxuatId) ON TblThucpham_thucan.Id = TblNhapxuathanghoa.Thucpham_ThucanId "
+ " WHERE     (TblHoadonnhapxuat.Trangthai = @Trangthai) AND (TblHoadonnhapxuat.NgayNX <= @ToNgay) AND                         (TblHoadonnhapxuat.NgayNX >= @FromNgay) ";
        public static string SPROC_TBL_TOTRONGNAM_ADD = "	INSERT INTO Tbl_Totrongnam"
 + " 	( "
 + " 		ToId, "
 + " 		Xeploai, "
 + " 		HockyId, "
 + " 		NamhocId "
 + " 	) "
 + " 	VALUES "
 + " 	( "
 + " 		@ToId, "
 + " 		'@Xeploai', "
 + " 		@HockyId, "
 + " 		@NamhocId "
 + " 	) ";
        public static string SPROC_TBL_TOTRONGNAM_COUNTBYNAMKYTO = "SELECT    count(Tbl_Totrongnam.Id)"
 + " FROM        ( Tbl_Totrongnam INNER JOIN "
 + "                       TblDm_Hocky ON Tbl_Totrongnam.HockyId = TblDm_Hocky.Id ) INNER JOIN "
 + "                       TblDm_To ON Tbl_Totrongnam.ToId = TblDm_To.Id "
 + " where(Tbl_Totrongnam.hockyId =@HockyId and Tbl_Totrongnam.NamhocId =@NamhocId and Tbl_Totrongnam.ToId =@ToId) ";
        public static string SPROC_TBL_TOTRONGNAM_GET = "SELECT     Tbl_Totrongnam.Id , Tbl_Totrongnam.ToId ,  Tbl_Totrongnam.HockyId , "
 + "                       Tbl_Totrongnam.NamhocId , TblDm_To.Tento, TblDm_Hocky.Tenloaiky,Tbl_Totrongnam.Xeploai "
 + " FROM         (Tbl_Totrongnam INNER JOIN "
 + "                       TblDm_Hocky ON Tbl_Totrongnam.HockyId = TblDm_Hocky.Id) INNER JOIN "
 + "                       TblDm_To ON Tbl_Totrongnam.ToId = TblDm_To.Id "
 + " where(Tbl_Totrongnam.hockyId =@HockyId and Tbl_Totrongnam.NamhocId =?) "
 + " order by TblDm_To.Tento ";
        public static string SPROC_TBL_TOTRONGNAM_UPDATE = "UPDATE Tbl_Totrongnam"
 + " SET Xeploai = '@Xeploai' "
 + " WHERE Id =@Id";
        public static string SPROC_TBLBANGCAP_ADD = "	INSERT INTO TblBangcap"
 + " 	( "
 + " 		NhanvienId, "
 + " 		Tentruong, "
 + " 		Loaitotnghiep, "
 + " 		Chuyennganhdaotao, "
 + " 		HedaotaoId, "
 + " 		Namtotnghiep, "
 + " 		LoaihinhdaotaoId "
 + " 	) "
 + " 	VALUES "
 + " 	( "
 + " 		?, "
 + " 		@Tentruong, "
 + " 		@Loaitotnghiep, "
 + " 		@Chuyennganhdaotao, "
 + " 		@HedaotaoId, "
 + " 		@Namtotnghiep, "
 + " 		@LoaihinhdaotaoId "
 + " 	) ";
        public static string SPROC_TBLBANGCAP_DELETE = "DELETE"
 + " FROM TblBangcap "
 + " WHERE Id =?";
        public static string SPROC_TBLBANGCAP_GET = "SELECT"
 + " 	TblBangcap.Id, "
 + " 	TblBangcap.NhanvienId, "
 + " 	TblBangcap.Tentruong, "
 + " 	TblBangcap.Loaitotnghiep, "
 + " 	TblBangcap.Chuyennganhdaotao, "
 + " 	TblBangcap.HedaotaoId, "
 + " 	TblBangcap.Namtotnghiep, "
 + " 	TblBangcap.LoaihinhdaotaoId, "
 + "     tblDm_Loaihinhdaotao.tenloaihinhdaotao, Tbldm_hedaotao.Tenhedaotao "
 + " FROM (TblBangcap "
 + " inner join tblDm_Loaihinhdaotao on TblDm_Loaihinhdaotao.Id =	TblBangcap.LoaihinhdaotaoId) "
 + " inner join tblDm_hedaotao on Tbldm_hedaotao.Id =TblBangcap.HedaotaoId "
 + " where(NhanvienId = ?) ";
        public static string SPROC_TBLBANGCAP_GETBYID = "SELECT"
 + " * "
 + " FROM TblBangcap "
 + " WHERE Id =?";
        public static string SPROC_TBLBANGCAP_UPDATE = "UPDATE TblBangcap"
 + " SET "
 + " 	Tentruong = \"@Tentruong\", "
 + " 	Loaitotnghiep = \"@Loaitotnghiep\", "
 + " 	Chuyennganhdaotao = \"@Chuyennganhdaotao\", "
 + " 	HedaotaoId = @HedaotaoId, "
 + " 	Namtotnghiep = @Namtotnghiep, "
 + " 	LoaihinhdaotaoId = @LoaihinhdaotaoId "
 + " WHERE Id = @Id";
        public static string SPROC_TBLBAOAN_ADD = "	INSERT INTO TblBaoan"
 + " 	( 	Ngay, "
 + " 		LophocId, "
 + " 		Tongsosuat, "
 + " 		Tongsotre, "
 + " 		ThanghocId ) "
 + " 	VALUES ( "
 + " 		@Ngay, "
 + " 		@LophocId, "
 + " 		@Tongsosuat, "
 + " 		@Tongsotre, "
 + " 		@ThanghocId ) ";
        public static string SPROC_TBLBAOAN_DELBYNAMHOCID = "delete "
 + " FROM         TblBaoan "
 + " where ( Id in "
 + " (	SELECT     TblBaoan.Id "
 + " FROM         TblBaoan INNER JOIN TblLop ON TblBaoan.LophocId = TblLop.Id "
 + " WHERE     (TblLop.NamhocId = ?))) ";
        public static string SPROC_TBLBAOAN_GETBYID = "SELECT   distinct ROW_NUMBER() OVER (ORDER BY Tenlop) AS STT,   TblBaoan.Id, TblLop.Id AS LophocId, TblLop.Tenlop, TblBaoan.Tongsosuat, TblBaoan.Tongsotre, TblBaoan.ThanghocId, "
 + "                       TblBaoan.Ngay "
 + " FROM TblLop INNER JOIN TblBaoan ON TblLop.Id = TblBaoan.LophocId "
 + " WHERE     (TblBaoan.ThanghocId = ?) AND (TblBaoan.Ngay = @Ngay) ";
        public static string SPROC_TBLBAOAN_RETURNSUM = "SELECT iif(ISNULL(SUM(TblBaoan.Tongsosuat) ), 0,SUM(TblBaoan.Tongsosuat) ) AS Tongsosuat, " +
" iif(ISNULL(SUM(TblBaoan.Tongsotre) ), 0,SUM(TblBaoan.Tongsotre) ) " +
" AS Tongsotre FROM (TblBaoan INNER JOIN TblLop ON TblBaoan.LophocId = TblLop.Id) " +
" INNER JOIN       TblDm_Phanloailop " +
 " ON TblLop.PhanloailopId = TblDm_Phanloailop.Id  " +
" WHERE (TblLop.NamhocId = @NamhocId) AND (TblBaoan.Ngay = @Ngay) " +
 " AND (TblDm_Phanloailop.KhoilopID = @KhoilopId) ";
        public static string SPROC_TBLBAOAN_UPDATE = "UPDATE TblBaoan"
 + " SET Ngay = @Ngay, "
 + " 	LophocId = @LophocId, "
 + " 	Tongsosuat = @Tongsosuat, "
 + " 	Tongsotre = @Tongsotre, "
 + " 	ThanghocId = @ThanghocId "
 + " WHERE Id =@Id";
        public static string SPROC_TBLBAOCAOTREKIEMTRASUCKHOE = ""
 + " SELECT COUNT(TblNamtrehoc.Id) AS Tongso, TblLop.Tenlop, TblTre.Gioitinh, TblTrekiemtrasuckhoe.Danhgia"
 + " FROM ((TblNamtrehoc INNER JOIN "
 + "        TblTrekiemtrasuckhoe ON TblNamtrehoc.Id = TblTrekiemtrasuckhoe.NamtrehocId) INNER JOIN "
 + "        TblLop ON TblNamtrehoc.LophocId = TblLop.Id) INNER JOIN "
 + "        TblTre ON TblNamtrehoc.TreId = TblTre.Id "
 + " WHERE TblNamtrehoc.NamhocId = @NamhocId AND TblTrekiemtrasuckhoe.ThanghocId = @ThanghocId "
 + " GROUP BY TblLop.Tenlop, TblTre.Gioitinh, TblTrekiemtrasuckhoe.Danhgia "
 + " ORDER BY TblLop.Tenlop DESC ";
        public static string SPROC_TBLCHITIETKIENTHUCNOITRO_ADD = "INSERT INTO TblChitietkienthucnoitro (LoaikienthucnoitroId, Tieude, Noidung) VALUES ( ?, ?, ?) ";
        public static string SPROC_TBLCHITIETKIENTHUCNOITRO_DELETE = "DELETE FROM TblChitietkienthucnoitro WHERE Id = ? ";
        public static string SPROC_TBLCHITIETKIENTHUCNOITRO_GETBYID = "SELECT * FROM TblChitietkienthucnoitro WHERE Id = ? ";
        public static string SPROC_TBLCHITIETKIENTHUCNOITRO_GETBYLOAIKIENTHUCNOITROID = "SELECT * FROM TblChitietkienthucnoitro WHERE LoaikienthucnoitroId = ? ";
        public static string SPROC_TBLCHITIETKIENTHUCNOITRO_GETBYNHOMKIENTHUCIDANDNAME = "SELECT Id, LoaikienthucnoitroId, Tieude, Noidung FROM TblChitietkienthucnoitro WHERE LoaikienthucnoitroId = @LoaikienthucnoitroId AND Tieude LIKE '%' + @Tieude + '%' ";
        public static string SPROC_TBLCHITIETKIENTHUCNOITRO_UPDATE = "UPDATE TblChitietkienthucnoitro SET Tieude = @Tieude, Noidung = @Noidung WHERE Id =?";

        public static string SPROC_TBLDANHSACHBAOAN = "SELECT TblBaoan.Id AS BaoanId, TblLop.Tenlop, TblBaoan.Tongsotre, TblBaoan.Tongsosuat, TblBaoan.Ngay, TblBaoan.LophocId, TblLop.NamhocId FROM TblBaoan INNER JOIN TblLop ON TblBaoan.LophocId = TblLop.Id WHERE TblBaoan.Ngay = @Ngay AND TblLop.NamhocId = @NamhocId";
        public static string SPROC_TBLDANHSACHNGUYENLIEUDUKIENMUA = "SELECT     Thucphamtheobua.Thucpham_ThucanId, TblThucpham_thucan.DonvitinhId, TblThucpham_thucan.Tenthucan,                        TblDm_Donvitinh.Tendonvitinh, " +
" iif( ISNULL(Thucphamtheobua.Dongia), 0,Thucphamtheobua.Dongia) AS Soluongcon, SUM(Thucphamtheobua.Soluong) AS Soluong,     " +
" iif( ISNULL(Thucphamtheobua.Dongia), 0,Thucphamtheobua.Dongia) AS Dongia, iif(ISNULL(Thucphamtheobua.Dongia), 0,Thucphamtheobua.Dongia) *iif( ISNULL(Thucphamtheobua.Soluong), 0,Thucphamtheobua.Soluong)                         AS Thanhtien, Thucphamtheobua.Ngay " +
" FROM         (TblThucpham_thucan INNER JOIN                        Thucphamtheobua ON TblThucpham_thucan.Id = Thucphamtheobua.Thucpham_ThucanId ) " +
" INNER JOIN                        TblDm_Donvitinh ON TblThucpham_thucan.DonvitinhId = TblDm_Donvitinh.Id   " +
" WHERE     (Thucphamtheobua.Ngay = @Ngay) " +
" GROUP BY TblThucpham_thucan.Tenthucan, TblThucpham_thucan.DonvitinhId, Thucphamtheobua.Thucpham_ThucanId,                         TblDm_Donvitinh.Tendonvitinh, "
+ " iif( ISNULL(Thucphamtheobua.Dongia), 0,Thucphamtheobua.Dongia),Thucphamtheobua.Ngay,iif( ISNULL(Thucphamtheobua.Dongia), 0,Thucphamtheobua.Dongia)                         * iif( ISNULL(Thucphamtheobua.Soluong), 0,Thucphamtheobua.Soluong) ";
        public static string SPROC_TBLDIEMDANHTRE_NULL = "SELECT Hovaten, Tenthuonggoi, NamtrehocId, LophocId FROM Vw_Tre_namtrehoc WHERE NamhocId = ? AND LophocId = ? ";
        public static string SPROC_TBLDIEMDANHTREAN_ADD = "INSERT INTO TblDiemdanhtrean (NamtrehocId, Ngay, ThanghocId, Trangthai) VALUES (?, ?, ?, ?) ";

        public static string SPROC_TBLDIEMDANHTREDIHOC_ADD = "INSERT INTO TblDiemdanhtrehoc (NamtrehocId, Ngay, ThanghocId, Trangthai) VALUES (@NamtrehocId, #@Ngay#, @ThanghocId, @Trangthai) ";
        public static string SPROC_TBLDIEMDANHTREDIHOC_EDIT = "Update  TblDiemdanhtrehoc  set Trangthai = @Trangthai where (Id =@Id) ";
        public static string SPROC_TBLDIEMDANHTREAN_GET = "SELECT TblDiemdanhtrean.Id, TblNamtrehoc.Id AS NamtrehocId, TblNamtrehoc.LophocId, TblTre.Hovaten, TblTre.Tenthuonggoi, "
 + "                       TblDiemdanhtrean.Trangthai, TblDiemdanhtrean.Ngay, TblDiemdanhtrean.ThanghocId, TblNamtrehoc.NamhocId "
 + " FROM (TblTre INNER JOIN TblNamtrehoc ON TblTre.Id = TblNamtrehoc.TreId) INNER JOIN "
 + "      TblDiemdanhtrean ON TblNamtrehoc.Id = TblDiemdanhtrean.NamtrehocId "
 + " WHERE (TblNamtrehoc.NamhocId = ?) AND (TblDiemdanhtrean.ThanghocId = ?) AND (TblNamtrehoc.LophocId = @LophocId)  "
 + "   AND (TblTre.Tinhtrang = 0) AND (TblDiemdanhtrean.Ngay = @Ngay) ";
        public static string SPROC_TBLDIEMDANHTREAN_RETURNCOUNTBUAAN = "SELECT COUNT(Id) AS Tongsotre, LophocId FROM TblNamtrehoc WHERE LophocId = ? GROUP BY LophocId ";
        public static string SPROC_TBLDIEMDANHTREAN_UPDATE = "UPDATE TblDiemdanhtrean"
 + " SET NamtrehocId = @NamtrehocId, Ngay = @Ngay, "
 + " 	ThanghocId = ?, Trangthai = ? "
 + " WHERE Id = ? ";
        public static string SPROC_TBLDIEMDANHTREDIHOC_GET = "SELECT     TblDiemdanhtrehoc.Id, TblNamtrehoc.Id AS NamtrehocId, TblNamtrehoc.LophocId, TblTre.Hovaten, TblTre.Tenthuonggoi, "
 + "                       TblDiemdanhtrehoc.Trangthai, TblDiemdanhtrehoc.Ngay, TblDiemdanhtrehoc.ThanghocId, TblNamtrehoc.NamhocId "
 + " FROM (TblTre INNER JOIN TblNamtrehoc ON TblTre.Id = TblNamtrehoc.TreId) INNER JOIN "
 + "       TblDiemdanhtrehoc ON TblNamtrehoc.Id = TblDiemdanhtrehoc.NamtrehocId "
 + " WHERE (TblNamtrehoc.NamhocId = @NamhocId) AND (TblNamtrehoc.LophocId = @LophocId) AND (TblTre.Tinhtrang = 0) AND  "
 + "       (TblDiemdanhtrehoc.ThanghocId = @ThanghocId) AND (TblDiemdanhtrehoc.Ngay = '@Ngay') ";
        public static string SPROC_TBLDIEMDANHTREDIHOC_GET1 = "SELECT TblDiemdanhtrehoc.Id, TblNamtrehoc.Id AS NamtrehocId, TblNamtrehoc.LophocId, TblTre.Hovaten, TblTre.Tenthuonggoi, (select Tendantoc from TblDm_Dantoc where Id = Tbltre.DantocId) AS Tendantoc, TblTre.ngaysinh,TblTre.gioitinh, TblDiemdanhtrehoc.Trangthai, TblDiemdanhtrehoc.Ngay, TblDiemdanhtrehoc.ThanghocId, TblNamtrehoc.NamhocId FROM TblDiemdanhtrehoc INNER JOIN (TblNamtrehoc INNER JOIN TblTre ON TblNamtrehoc.TreId = TblTre.Id) ON TblDiemdanhtrehoc.NamtrehocId = TblNamtrehoc.Id WHERE (((TblNamtrehoc.LophocId)=@LophocId) AND ((TblDiemdanhtrehoc.Ngay)=#@Ngay#) AND ((TblDiemdanhtrehoc.ThanghocId)=@ThanghocId) AND ((TblNamtrehoc.NamhocId)=@NamhocId) AND ((TblTre.Tinhtrang)=0))";
        public static string SPROC_TBLLenlopTREDIHOC_GET1 = "SELECT TblDiemdanhtrehoc.Id, TblNamtrehoc.Id AS NamtrehocId, TblNamtrehoc.LophocId, TblTre.Hovaten, TblTre.Id AS TreId,TblTre.Tenthuonggoi, TblDiemdanhtrehoc.Trangthai, TblDiemdanhtrehoc.Ngay, TblDiemdanhtrehoc.ThanghocId, TblNamtrehoc.NamhocId FROM TblDiemdanhtrehoc INNER JOIN (TblNamtrehoc INNER JOIN TblTre ON TblNamtrehoc.TreId = TblTre.Id) ON TblDiemdanhtrehoc.NamtrehocId = TblNamtrehoc.Id WHERE (((TblNamtrehoc.LophocId)=@LophocId) AND ((TblDiemdanhtrehoc.Ngay)=#@Ngay#) AND ((TblDiemdanhtrehoc.ThanghocId)=@ThanghocId) AND ((TblNamtrehoc.NamhocId)=@NamhocId) AND ((TblTre.Tinhtrang)=0))";
        public static string SPROC_TBLDIEMDANHTREDIHOC_GET2 = "SELECT TblDiemdanhtrehoc.Id, TblNamtrehoc.Id AS NamtrehocId, TblNamtrehoc.LophocId, TblTre.Hovaten, TblTre.Tenthuonggoi,(select Tendantoc from TblDm_Dantoc where Id = Tbltre.DantocId) AS Tendantoc, TblTre.ngaysinh,TblTre.gioitinh, TblDiemdanhtrehoc.Trangthai, TblDiemdanhtrehoc.Ngay, TblDiemdanhtrehoc.ThanghocId, TblNamtrehoc.NamhocId FROM TblDiemdanhtrehoc INNER JOIN (TblNamtrehoc INNER JOIN TblTre ON TblNamtrehoc.TreId = TblTre.Id) ON TblDiemdanhtrehoc.NamtrehocId = TblNamtrehoc.Id WHERE (TblNamtrehoc.NamhocId = @NamhocId) and (TblTre.Tinhtrang = 0)  and (TblDiemdanhtrehoc.ThanghocId = @ThanghocId) and  (TblDiemdanhtrehoc.Ngay = #@Ngay#)";
        public static string SPROC_TBLLenlopTREDIHOC_GET2 = "SELECT TblDiemdanhtrehoc.Id, TblNamtrehoc.Id AS NamtrehocId, TblNamtrehoc.LophocId, TblTre.Hovaten,  TblTre.Id AS TreId,TblTre.Tenthuonggoi, TblDiemdanhtrehoc.Trangthai, TblDiemdanhtrehoc.Ngay, TblDiemdanhtrehoc.ThanghocId, TblNamtrehoc.NamhocId FROM TblDiemdanhtrehoc INNER JOIN (TblNamtrehoc INNER JOIN TblTre ON TblNamtrehoc.TreId = TblTre.Id) ON TblDiemdanhtrehoc.NamtrehocId = TblNamtrehoc.Id WHERE (TblNamtrehoc.NamhocId = @NamhocId) and (TblTre.Tinhtrang = 0)  and (TblDiemdanhtrehoc.ThanghocId = @ThanghocId) and  (TblDiemdanhtrehoc.Ngay = #@Ngay#)";


        public static string SPROC_TBLDIEMTRUONG_ADD = "INSERT INTO TblDiemtruong(TruongId, Tendiem, Diachi, Dienthoai, Email, Trangthaitrungtam) VALUES (?, ?, ?, ?, ?, ? )";
        public static string SPROC_TBLDIEMTRUONG_DELETEBYID = "DELETE FROM TblDiemtruong where Id=? ";
        public static string SPROC_TBLDIEMTRUONG_GET = "SELECT * FROM TblDiemtruong ORDER BY Tendiem ";
        public static string SPROC_TBLDIEMTRUONG_GETBYID = "SELECT * FROM TblDiemtruong WHERE Id = ? ";
        public static string SPROC_TBLDIEMTRUONG_GETBYTENDIEMTRUONG = "SELECT * FROM TblDiemtruong WHERE Tendiem = ? and TruongId = ? ";
        public static string SPROC_TBLDIEMTRUONG_UPDATE = "UPDATE TblDiemtruong"
 + " SET TruongId = ?, Tendiem = ?, Diachi = ?, Dienthoai = ?, Email = ?, Trangthaitrungtam = ? "
 + " WHERE Id = ? ";
        public static string SP_BUAANTRONGNGAY_GETBYID = "SELECT * FROM TblDm_Buaantrongngay WHERE Id = ? ";
        public static string SP_DOTUOI_ADD = "INSERT INTO TblDm_Dotuoi(Tuoicanduoi, Tuoicantren, Tendotuoi) VALUES ( @Tuoicanduoi, @Tuoicantren,'@Tendotuoi') ";
        public static string SP_DOTUOI_DEL = "delete FROM TblDm_Dotuoi WHERE Id = @Id ";
        public static string SP_DOTUOI_GET = "SELECT * FROM TblDm_Dotuoi ORDER BY Tendotuoi";
        public static string SP_DOTUOI_GETBYID = "SELECT * FROM TblDm_Dotuoi WHERE Id = @Id ";
        public static string SP_DOTUOI_GETBYNAME = "SELECT * FROM TblDm_Dotuoi WHERE Tendotuoi = '@Tendotuoi' ";
        public static string SP_DOTUOI_UPDATE = "UPDATE TblDm_Dotuoi SET Tuoicanduoi = @Tuoicanduoi, Tuoicantren = @Tuoicantren, Tendotuoi = '@Tendotuoi' WHERE Id = @Id ";

        public static string SP_HUYEN_GETBYTENHUYEN = "SELECT * FROM TblDm_Huyen WHERE Tenhuyen = '@Ten' and TinhId = @TinhId ";

        public static string SP_KHOILOP_ADD = "	INSERT INTO TblDm_Khoilop(Tenkhoilop) VALUES(?)";
        public static string SP_KHOILOP_DEL = "delete from TblDm_Khoilop WHERE Id = @Id ";
        public static string SP_KHOILOP_GET = "SELECT Id, Tenkhoilop FROM TblDm_Khoilop ";
        public static string SP_KHOILOP_UPDATE = "UPDATE TblDm_Khoilop SET Tenkhoilop = ? WHERE Id = ? ";

        public static string SP_LOAIHINHDAOTAO_ADD = "INSERT INTO TblDm_Loaihinhdaotao (Tenloaihinhdaotao) VALUES ('@Tenloaihinhdaotao') ";
        public static string SP_LOAIHINHDAOTAO_DEL = "delete FROM TblDm_Loaihinhdaotao WHERE Id = @Id ";
        public static string SP_LOAIHINHDAOTAO_GET = "SELECT * FROM TblDm_Loaihinhdaotao ORDER BY Tenloaihinhdaotao";
        public static string SP_LOAIHINHDAOTAO_UPDATE = "UPDATE TblDm_Loaihinhdaotao SET Tenloaihinhdaotao = '@Tenloaihinhdaotao' WHERE Id = @Id ";

        public static string SP_LOAIKIENTHUCNOITRO_ADD = "INSERT INTO TblDm_Loaikienthucnoitro( Tenloaikienthucnoitro ) VALUES ( ? ) ";
        public static string SP_LOAIKIENTHUCNOITRO_DEL = "delete  from TblDm_Loaikienthucnoitro where Id = ? ";
        public static string SP_LOAIKIENTHUCNOITRO_GET = "SELECT * FROM TblDm_Loaikienthucnoitro ";
        public static string SP_LOAIKIENTHUCNOITRO_UPDATE = "UPDATE TblDm_Loaikienthucnoitro SET Tenloaikienthucnoitro = ? WHERE Id =?";

        public static string SP_LOAIMON_ADD = "INSERT INTO TblDm_Loaimon (Tenloaimon) VALUES ( ? )";
        public static string SP_LOAIMON_DEL = "delete FROM TblDm_Loaimon WHERE Id = ?";
        public static string SP_LOAIMON_GET = "SELECT * FROM TblDm_Loaimon ORDER BY Tenloaimon";
        public static string SP_LOAIMON_UPDATE = "UPDATE TblDm_Loaimon SET Tenloaimon = ? WHERE Id = ? ";

        public static string SP_NAMHOC_ADD = "INSERT INTO TblDm_Namhoc (Nambatdau, Namketthuc, Trangthai, Tennamhoc) VALUES(@Nambatdau,@Namketthuc,@Trangthai, '@Tennamhoc')";
        public static string SP_NAMHOC_UPDATE = "UPDATE TblDm_Namhoc SET Nambatdau = @Nambatdau, Namketthuc = @Namketthuc, Trangthai = @Trangthai, Tennamhoc ='@Tennamhoc'  WHERE Id = @Id ";
        public static string SP_NAMHOC_BYID = "SELECT *  FROM TblDm_Namhoc WHERE Id =@Id";
        public static string SP_NAMHOC_GET = "SELECT * FROM TblDm_Namhoc order by Nambatdau ";
        public static string SP_NAMHOC_GETCOUNTSELECTED = "SELECT COUNT(Id) FROM TblDm_Namhoc where (Trangthai = -1)";
        public static string SP_NAMHOC_GETNAMHOCID = "SELECT * FROM TblDm_Namhoc WHERE Trangthai = -1 ";

        public static string SP_PHANLOAICANBO_ADD = "INSERT INTO TblDm_Phanloaicanbo(Phanloaicanbo) VALUES ( @Phanloaicanbo ) ";
        public static string SP_PHANLOAICANBO_GET = "SELECT * FROM TblDm_Phanloaicanbo ORDER BY Phanloaicanbo";
        public static string SP_PHANLOAICANBO_GETBYCHUCVUID = "SELECT"
 + "	TblDm_Phanloaicanbo.Id, TblDm_Phanloaicanbo.Phanloaicanbo "
 + " FROM TblDm_Phanloaicanbo "
 + " inner join TblDm_Chucvu on TblDm_Phanloaicanbo.Id = TblDm_Chucvu.PhanloaicanboId "
 + " where (TblDm_Chucvu.Id = @ChucvuId) ";
        public static string SP_PHANLOAICANBO_UPDATE = "UPDATE TblDm_Phanloaicanbo SET Phanloaicanbo = @Phanloaicanbo  WHERE Id =@Id";
        public static string SP_THANGHOC_ADD = "INSERT INTO TblDm_Thanghoc (NamhocId, Thang, Nam, Thang_Nam) VALUES (?, ?, ?, ?) ";
        public static string SP_THANGHOC_GETBYNAMHOCID = "SELECT * FROM TblDm_Thanghoc WHERE NamhocId = ? ORDER BY Thang ";
        public static string SP_THANGHOC_GETBYNAMHOCID_NAM = "SELECT Id, Thang, Nam FROM TblDm_Thanghoc WHERE NamhocId = @NamhocId  and Nam =@Nam ORDER BY Nam ";

        public static string SP_THUDAUNAM_ADD = "INSERT INTO TblDm_Thudaunam (Tenmucthu, Dm_Nhatre, Dm_Maugiao, Dm_Nhombot, Dm_Nhomchao) VALUES( '@Tenmucthu', '@Dm_Nhatre', '@Dm_Maugiao', '@Dm_Nhombot', '@Dm_Nhomchao')";
        public static string SP_THUDAUNAM_DEL = "delete FROM TblDm_Thudaunam WHERE Id = ?";
        public static string SP_THUDAUNAM_GET = "SELECT  * FROM	TblDm_Thudaunam ORDER BY Tenmucthu";
        public static string SP_THUDAUNAM_GETBYID = "SELECT * FROM TblDm_Thudaunam WHERE Id =@Id";
        public static string SP_THUDAUNAM_UPDATE = "UPDATE TblDm_Thudaunam SET Tenmucthu = '@Tenmucthu', Dm_Nhatre = '@Dm_Nhatre', Dm_Maugiao = '@Dm_Maugiao', Dm_Nhombot='@Dm_Nhombot', Dm_Nhomchao='@Dm_Nhomchao' WHERE Id =@Id";

        public static string SP_THUTHEOTHANG_GETBYID = "SELECT * FROM TblDm_Thutheothang WHERE Id =@Id";
        public static string SP_THUTHEOTHANG_SELECTALLCHECK = "SELECT     TblDm_Thutheothang.Id, TblDm_Thutheothang.Tenmucthu, TblDm_Thutheothang.Phi_Nhatre, TblDm_Thutheothang.Phi_Maugiao, "
 + "                       TblDm_Thutheothang.Phi_Nhombot, TblDm_Thutheothang.Phi_Nhomchao, TblDm_Thutheothang.ThanghocId,  "
 + "                     iif(TblDm_Thutheothang.Canam=Null,0,TblDm_Thutheothang.Canam)    AS Canam "
 + " FROM         TblDm_Thutheothang INNER JOIN "
 + "                       TblDm_Thanghoc ON TblDm_Thutheothang.ThanghocId = TblDm_Thanghoc.Id "
 + " WHERE     (TblDm_Thanghoc.NamhocId = @NamhocId) AND ( iif(TblDm_Thutheothang.Canam =Null,0,TblDm_Thutheothang.Canam) = -1) ";
        public static string SP_THUVIENMONAN_ADD = "	INSERT INTO TblDm_Thuvienmonan"
 + "       (Tenmonan, DotuoiId, LoaimonId, Motasudung, Nguyenlieu, Thuchien, Hinhanh, Chuthich, Trichnguon) "
 + "VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?) ";
        public static string SP_THUVIENMONAN_GETBYID0 = " "
 + " SELECT TblDm_Thuvienmonan.Id, TblDm_Thuvienmonan.Tenmonan, "
 + " TblDm_Thuvienmonan.DotuoiId, TblDm_Thuvienmonan.LoaimonId, "
 + " TblDm_Thuvienmonan.Motasudung, TblDm_Thuvienmonan.Nguyenlieu, "
 + " TblDm_Thuvienmonan.Thuchien, TblDm_Thuvienmonan.Hinhanh, "
 + " TblDm_Thuvienmonan.Chuthich, TblDm_Thuvienmonan.Trichnguon "
 + " FROM TblDm_Thuvienmonan inner join TblDm_Loaimon on TblDm_Thuvienmonan.LoaimonId = TblDm_Loaimon.Id "
 + " WHERE TblDm_Thuvienmonan.LoaimonId= ? and TblDm_Thuvienmonan.DotuoiId = 0 "
 + " order by TblDm_Thuvienmonan.DotuoiId desc ";

        public static string SP_THUVIENMONAN_GETBYID1 = " "
        + " SELECT TblDm_Thuvienmonan.Id, TblDm_Thuvienmonan.Tenmonan, "
        + " TblDm_Thuvienmonan.DotuoiId,  TblDm_Thuvienmonan.LoaimonId, "
        + " TblDm_Thuvienmonan.Motasudung, TblDm_Thuvienmonan.Nguyenlieu, "
        + " TblDm_Thuvienmonan.Thuchien, TblDm_Thuvienmonan.Hinhanh, "
        + " TblDm_Thuvienmonan.Chuthich, TblDm_Thuvienmonan.Trichnguon "
        + " FROM TblDm_Thuvienmonan inner join TblDm_Loaimon on TblDm_Thuvienmonan.LoaimonId = TblDm_Loaimon.Id "
        + " WHERE TblDm_Thuvienmonan.LoaimonId= ? and (TblDm_Thuvienmonan.DotuoiId = ? or TblDm_Thuvienmonan.DotuoiId  ='0') "
        + " order by TblDm_Thuvienmonan.DotuoiId desc ";
        public static string SP_THUVIENMONAN_GETBYLOAIMONANID = "SELECT"
 + " TblDm_Thuvienmonan.Id, "
 + " TblDm_Thuvienmonan.Tenmonan, "
 + " TblDm_Thuvienmonan.DotuoiId, "
 + " TblDm_Thuvienmonan.LoaimonId, "
 + " TblDm_Thuvienmonan.Motasudung, "
 + " TblDm_Thuvienmonan.Nguyenlieu, "
 + " TblDm_Thuvienmonan.Thuchien, "
 + " TblDm_Thuvienmonan.Hinhanh, "
 + " TblDm_Thuvienmonan.Chuthich, "
 + " TblDm_Thuvienmonan.Trichnguon "
 + " FROM TblDm_Thuvienmonan inner join TblDm_Loaimon on TblDm_Thuvienmonan.LoaimonId = TblDm_Loaimon.Id "
 + " WHERE TblDm_Thuvienmonan.LoaimonId= @LoaimonId  "
 + " order by TblDm_Thuvienmonan.DotuoiId desc ";
        public static string SP_THUVIENMONAN_GETBYLOAIMONIDANDTENMONAN = "SELECT"
 + " * FROM TblDm_Thuvienmonan "
 + " WHERE LoaimonId = ? and Tenmonan like '%' +@Tenmonan+ '%' ";
        public static string SP_THUVIENMONAN_GETBYTOPN_ID = "SELECT max(Id) as Id FROM TblDm_Thuvienmonan ";
        public static string SP_THUVIENMONAN_UPDATE = "UPDATE TblDm_Thuvienmonan"
 + " SET Tenmonan='@Tenmonan',DotuoiId=@DotuoiId,LoaimonId=@LoaimonId,Motasudung='@Motasudung',Nguyenlieu='@Nguyenlieu',Thuchien='@Thuchien',Hinhanh='@Hinhanh',Chuthich='@Chuthich',Trichnguon='@Trichnguon' "
 + " WHERE Id=@Id ";
        public static string SPROC_TBLGIA_ADD = "INSERT INTO TblGia(Giatien) VALUES (@Giatien)";
        public static string SPROC_TBLGIA_GET = "SELECT * FROM TblGia ";
        public static string SPROC_TBLGIA_UPDATE = "UPDATE TblGia SET Giatien = @Giatien WHERE Id = @Id";

        public static string SPROC_TBLHOADONNHAPXUAT_ADD = "INSERT INTO TblHoadonnhapxuat (NgayNX, Tongtien, Trangthai, NamhocId ) VALUES ( ?, ?, ?, ? )";
        public static string SPROC_TBLHOADONNHAPXUAT_DELEBYHOADON = "DELETE FROM TblHoadonnhapxuat where Id =@HoadonnhapxuatId";
        public static string SPROC_TBLHOADONNHAPXUAT_DELEBYNAMHOCID = "delete FROM TblHoadonnhapxuat WHERE NamhocId = ? ";
        public static string SPROC_TBLHOADONNHAPXUAT_GET = "SELECT"
 + " 	Id, NgayNX, Tongtien, Trangthai "
 + " FROM TblHoadonnhapxuat "
 + " where Trangthai = @Trangthai and NgayNX = @NgayNX "
 + " ORDER BY Id DESC ";
        public static string SPROC_TBLHOPDONGNHANVIEN_ADD = "INSERT INTO TblHopdongnhanvien(NhanviencongtacId, LoaihopdongId, Ngayhopdong, Ghichu ) VALUES ( ?, ?, ?, ?) ";
        public static string SPROC_TBLHOPDONGNHANVIEN_DEL = "delete from TblHopdongnhanvien where Id = ? ";
        public static string SPROC_TBLHOPDONGNHANVIEN_GET = "SELECT"
 + " 	TblHopdongnhanvien.Id, "
 + " 	TblHopdongnhanvien.NhanviencongtacId, "
 + " 	TblHopdongnhanvien.LoaihopdongId, "
 + " 	TblHopdongnhanvien.Ngayhopdong, "
 + " 	TblHopdongnhanvien.Ghichu, TblDm_Loaihopdong.Tenhopdong "
 + " FROM "
 + " 	TblHopdongnhanvien "
 + " inner join TblDm_Loaihopdong on TblHopdongnhanvien.LoaihopdongId =TblDm_Loaihopdong.Id "
 + " where(Nhanviencongtacid =@NhanviencongtacId and LoaihopdongId =@LoaihopdongId) ";
        public static string SPROC_TBLHOPDONGNHANVIEN_UPDATE = "UPDATE TblHopdongnhanvien"
 + " SET  "
 + " 	LoaihopdongId = '@LoaihopdongId', "
 + " 	Ngayhopdong = #@Ngayhopdong#, "
 + " 	Ghichu = @Ghichu "
 + " WHERE Id =@Id";
        public static string SPROC_TBLLENTHUCPHAMMONANCHOBUA_ADD = "INSERT INTO TblLenthucphammonanchobua (BaoanId, Thucpham_ThucanId, Soluong, Dongia, Dongiathucte) VALUES (?, ?, ?, ?, ?) ";
        public static string SPROC_TBLLENTHUCPHAMMONANCHOBUA_DELETEBYBAOANID = "DELETE FROM TblLenthucphammonanchobua WHERE     (TblLenthucphammonanchobua.BaoanId = ?) ";
        public static string SPROC_TBLLENTHUCPHAMMONANCHOBUA_DELETEBYID = "DELETE FROM TblLenthucphammonanchobua WHERE     (TblLenthucphammonanchobua.Id = ?) ";
        public static string SPROC_TBLLENTHUCPHAMMONANCHOBUA_GETBYBAOANID = "SELECT     TblLenthucphammonanchobua.Id, TblLenthucphammonanchobua.BaoanId, TblLenthucphammonanchobua.Thucpham_ThucanId, "
 + "                       TblThucpham_thucan.Tenthucan AS Tennguyenlieu, TblLenthucphammonanchobua.Soluong,  "
 + "                       ISNULL(TblLenthucphammonanchobua.Dongia, 0) AS Dongia ,TblDm_Donvitinh.Tendonvitinh "
 + " FROM         TblLenthucphammonanchobua INNER JOIN "
 + "                       TblThucpham_thucan ON TblLenthucphammonanchobua.Thucpham_ThucanId = TblThucpham_thucan.Id INNER JOIN "
 + "                       TblDm_Donvitinh ON TblThucpham_thucan.DonvitinhId = TblDm_Donvitinh.Id "
 + " WHERE     (TblLenthucphammonanchobua.BaoanId = ?) ";
        public static string SPROC_TBLLENTHUCPHAMMONANCHOBUA_UPDATE = "	UPDATE TblLenthucphammonanchobua SET Dongiathucte = ? WHERE Id = ? ";
        public static string SPROC_TBLLENTHUCPHAMMONANCHOBUA_UPDATEBYSOLUONGDONGIA = "	UPDATE TblLenthucphammonanchobua SET Dongia = ?, Soluong = ? WHERE Id =?";
        public static string SPROC_TBLLENTHUCPHAMMONANCHOBUATHUCTE_GETBYBAOANID = "SELECT     TblLenthucphammonanchobua.Id, TblLenthucphammonanchobua.BaoanId, TblLenthucphammonanchobua.Thucpham_ThucanId, "
 + "                       TblThucpham_thucan.Tenthucan AS Tennguyenlieu, TblLenthucphammonanchobua.Soluong,  "
 + "                       ISNULL(TblLenthucphammonanchobua.Dongiathucte, 0) AS Dongiathucte, TblDm_Donvitinh.Tendonvitinh "
 + " FROM         TblLenthucphammonanchobua INNER JOIN "
 + "                       TblThucpham_thucan ON TblLenthucphammonanchobua.Thucpham_ThucanId = TblThucpham_thucan.Id INNER JOIN "
 + "                       TblDm_Donvitinh ON TblThucpham_thucan.DonvitinhId = TblDm_Donvitinh.Id "
 + " WHERE TblLenthucphammonanchobua.BaoanId = ? ";
        public static string SPROC_TBLLOP_ADD = "INSERT INTO TblLop (Tenlop, PhonghocId, NamhocId, DotuoiId, PhanloailopId, Bantru ) VALUES ( ?, ?, ?, ?, ?, ?) ";
        public static string SPROC_TBLLOP_DELETE = "DELETE FROM TblLop WHERE Id = ?";
        public static string SPROC_TBLLOP_DELETEBYNAMHOCID = "DELETE FROM TblLop WHERE NamhocId = ? ";
        public static string SPROC_TBLLOP_GET = "SELECT"
 + " 	TblLop.Id, "
 + " 	TblLop.Tenlop, "
 + " 	TblLop.PhonghocId, "
 + " 	TblLop.NamhocId, "
 + " 	TblLop.DotuoiId, "
 + " 	TblLop.PhanloailopId, "
 + " 	TblLop.Bantru, TblDm_Dotuoi.Tendotuoi, TblDm_Phanloailop.Tenloailop, TblPhonghoc.Tenphong "
 + " FROM ((TblLop "
 + " inner join TblPhonghoc on TblPhonghoc.Id = Tbllop.PhonghocId) "
 + " inner join TblDm_Phanloailop on TblDm_Phanloailop.Id = Tbllop.PhanloailopId) "
 + " inner join TblDm_Dotuoi on TblDm_Dotuoi.Id = Tbllop.DotuoiId "
 + " where NamhocId=? and PhonghocId=@PhonghocId and PhanloailopId=? and DotuoiId=@DotuoiId "
 + " ORDER BY TblLop.Tenlop ";
        public static string SP_LOP_GETALL = ""
 + " SELECT TblLop.Id, TblLop.Tenlop, TblLop.PhonghocId, TblLop.NamhocId, TblLop.DotuoiId, TblLop.PhanloailopId, TblLop.Bantru "
 + " FROM TblLop WHERE NamhocId = @NamhocId ORDER BY TblLop.Tenlop ";
        public static string SPROC_TBLLOP_GETBYID = "SELECT     TblLop.Id, Tenlop, PhonghocId, NamhocId, DotuoiId, PhanloailopId, Bantru, tbldm_phanloailop.khoilopid"
 + " FROM         TblLop, tbldm_phanloailop "
 + " WHERE     (TblLop.Id = @Id) and TblLop.PhanloailopId= tbldm_phanloailop.id ";
        public static string SPROC_TBLLOP_GETBYPHANLOAILOPID = "SELECT * FROM TblLop WHERE PhanloailopId = ? ";
        public static string SPROC_TBLLOP_GETBYPHONGHOCID = "SELECT * FROM TblLop WHERE PhonghocId = ? ";
        public static string SPROC_TBLLOP_GETBYPHONGHOCID_NAMHOCID_DOTUOIID_PHANLOAILOPID_NAME = "SELECT"
 + " 	Id as LophocId "
 + " FROM TblLop WHERE "
 + " 	PhonghocId = @PhonghocId and NamhocId = ? and "
 + " 	DotuoiId =@DotuoiId and PhanloailopId =? and "
 + " 	Tenlop like '%' +@Tenlop+ '%' ";
        public static string SPROC_TBLLOP_RETURNTENKHOIBYLOPHOCID = "SELECT DISTINCT TblDm_Khoilop.Tenkhoilop, TblNamtrehoc.LophocId"
 + " FROM         TblNamtrehoc INNER JOIN "
 + "                       TblLop ON TblNamtrehoc.LophocId = TblLop.Id INNER JOIN "
 + "                       TblDm_Phanloailop ON TblLop.PhanloailopId = TblDm_Phanloailop.Id INNER JOIN "
 + "                       TblDm_Khoilop ON TblDm_Phanloailop.KhoilopID = TblDm_Khoilop.Id "
 + " WHERE     (TblNamtrehoc.LophocId = @LophocId) ";
        public static string SPROC_TBLLOP_SELECTALL = "SELECT"
 + " 	TblLop.Id, "
 + " 	TblLop.Tenlop, "
 + " 	TblLop.PhonghocId, "
 + " 	TblLop.NamhocId, "
 + " 	TblLop.DotuoiId, "
 + " 	TblLop.PhanloailopId,Doclap,ChuongtrinhGDId , "
 + " 	TblLop.Bantru, TblDm_Dotuoi.Tendotuoi, TblDm_Phanloailop.Tenloailop, TblPhonghoc.Tenphong  "
 + " FROM ((TblLop "
 + " inner join TblPhonghoc on TblPhonghoc.Id = Tbllop.PhonghocId) "
 + " inner join TblDm_Phanloailop on TblDm_Phanloailop.Id = Tbllop.PhanloailopId) "
 + " inner join TblDm_Dotuoi on TblDm_Dotuoi.Id = Tbllop.DotuoiId "
 + " where (NamhocId = ? ) "
 + " ORDER BY TblLop.Tenlop ";
        public static string SPROC_TBLLOP_UPDATE = "UPDATE TblLop"
 + " SET Tenlop = ?, "
 + " 	PhonghocId = ?, "
 + " 	NamhocId = ?, "
 + " 	DotuoiId = ?, "
 + " 	PhanloailopId = ?, "
 + " 	Bantru = ? "
 + " WHERE Id =?";
        public static string SPROC_TBLMONAN_THUCPHAM_ADD = "INSERT INTO TblMonan_Thucpham"
 + " 	( 	Thucpham_ThucanId, "
 + " 		ThuvienmonanId, "
 + " 		Soluong ) "
 + " 	VALUES "
 + " 	( 	@Thucpham_ThucanId, "
 + " 		@ThuvienmonanId, "
 + " 		@Soluong ) ";
        public static string SPROC_TBLMONAN_THUCPHAM_DELETE = "DELETE FROM TblMonan_Thucpham WHERE ThuvienmonanId = ? ";
        public static string SPROC_TBLMONAN_THUCPHAM_GETBYTHUVIENMONANID = "SELECT TblMonan_Thucpham.Thucpham_ThucanId,   TblThucpham_thucan.Tenthucan AS ListTenthucan, TblMonan_Thucpham.Soluong,     TblDm_Donvitinh.Tendonvitinh AS ListTendonvitinh, TblMonan_Thucpham.Id AS ListId,    TblMonan_Thucpham.ThuvienmonanId  FROM  " +
" ((TblThucpham_thucan INNER JOIN    TblMonan_Thucpham ON TblThucpham_thucan.Id = TblMonan_Thucpham.Thucpham_ThucanId) " +
 " INNER JOIN    TblDm_Thuvienmonan ON TblMonan_Thucpham.ThuvienmonanId = TblDm_Thuvienmonan.Id) " +
 " INNER JOIN    TblDm_Donvitinh ON TblThucpham_thucan.DonvitinhId = TblDm_Donvitinh.Id   " +
" WHERE TblMonan_Thucpham.ThuvienmonanId = @ThuvienmonanId ";
        public static string SPROC_TBLMUCGIAMUUTIENNAM_ADD = "	INSERT INTO TblMucgiamuutiennam (UutienId, Dinhmucgiam, ThudaunamId) VALUES (?,?,?) ";
        public static string SPROC_TBLMUCGIAMUUTIENNAM_DELETE = "DELETE"
 + " FROM TblMucgiamuutiennam "
 + " WHERE ThudaunamId = @ThudaunamId ";
        public static string SPROC_TBLMUCGIAMUUTIENNAM_GET = "SELECT * FROM Vw_TblMucuutiennam where (ThudaunamId = ?) ";
        public static string SPROC_TBLMUCGIAMUUTIENNAM_UPDATE = "UPDATE TblMucgiamuutiennam"
 + " SET UutienId = ?, "
 + " 	Dinhmucgiam = ?, "
 + " 	ThudaunamId = ? "
 + " WHERE Id = ?";
        public static string SP_UUTIENTHANG_INSERT = "INSERT INTO TblMucgiamuutienthang"
 + " 	( 	ThutheothangId, "
 + " 		ThanghocId, "
 + " 		UutienId, "
 + " 		Dinhmucgiam "
 + " 	) VALUES (?, ?, ?, ? ) ";
        public static string SPROC_TBLMUCGIAMUUTIENTHANG_GETBYID = "SELECT     TblDm_Uutien.Tenuutien, TblMucgiamuutienthang.Id , "
 + "                       TblMucgiamuutienthang.UutienId, TblMucgiamuutienthang.Dinhmucgiam, TblMucgiamuutienthang.ThutheothangId "
 + " FROM         TblDm_Uutien INNER JOIN "
 + "                       TblMucgiamuutienthang ON TblDm_Uutien.Id = TblMucgiamuutienthang.UutienId "
 + " WHERE "
 + " 	TblMucgiamuutienthang.ThutheothangId = @ThutheothangId and TblMucgiamuutienthang.ThanghocId = ? ";
        public static string SPROC_TBLMUCGIAMUUTIENTHANG_UPDATE = "UPDATE TblMucgiamuutienthang"
 + " SET Dinhmucgiam = ? "
 + " WHERE "
 + " 	Id =? and UutienId = ? ";
        public static string SP_MUCGIAMUUTIENTHANG_SELECTBYTHUTHEOTHANGID = "SELECT     ThutheothangId, ThanghocId, UutienId, Dinhmucgiam, Id"
 + " FROM         TblMucgiamuutienthang "
 + " WHERE     (ThutheothangId = ?) ";
        public static string SPROC_TBLNAMTREHOC_ADD = "	INSERT INTO TblNamtrehoc"
 + " 	( 	TreId, "
 + " 		LophocId, "
 + " 		NamhocId, "
 + " 		Tinhtrang "
 + " 	) "
 + " 	VALUES "
 + " 	( ?, ?, ?, ?) ";
        public static string SPROC_TBLNAMTREHOC_ADDLENLOP = "	INSERT INTO TblNamtrehoc"
 + "            (TreId "
 + "            ,LophocId "
 + "            ,NamhocId "
 + "            ,Tinhtrang) "
 + " (SELECT TreId "
 + "       ,@NewLophocId "
 + "       ,@NewNamhocId "
 + "       ,Tinhtrang "
 + "   FROM TblNamtrehoc where (NamhocId=@OldNamhocId) and (LophocId =@OldLophocId) ) ";
        public static string SPROC_TBLNAMTREHOC_CHUYENLOP = "UPDATE TblNamtrehoc"
             + " SET LophocId = ? "
             + " WHERE Id =?";
        public static string SPROC_TBLNAMTREHOC_COUNTTRE = "SELECT     COUNT(Id) AS Tongsotre, LophocId"
             + " FROM         TblNamtrehoc "
             + " WHERE     (LophocId = ?) "
             + " GROUP BY LophocId ";
        public static string SPROC_TBLNAMTREHOC_DEL = "	"
             + " delete  from TblTre where  Id in( "
             + " SELECT     TblTre.Id "
             + " FROM         TblTre INNER JOIN "
             + "                       TblNamtrehoc ON TblTre.Id = TblNamtrehoc.TreId "
             + " WHERE     (TblNamtrehoc.Id = ?)) ";
        public static string SPROC_TBLNAMTREHOC_DEL1 = "	"
           + " delete  from TblTre where  Id =@TreId";

        public static string SPROC_TBLNAMTREHOC_DEL2 = "	"
           + " delete  from TblNamtrehoc  where TblNamtrehoc.Id =@NamtrehocId";

        public static string SPROC_TBLNAMTREHOC_GET = "if(@LophocId =-1)"
 + " SELECT "
 + " 	TblNamtrehoc.Id, "
 + " 	TblNamtrehoc.TreId, "
 + " 	TblNamtrehoc.LophocId, "
 + " 	TblNamtrehoc.NamhocId, "
 + " 	TblNamtrehoc.Tinhtrang, "
 + " TblTre.Hovaten,  "
 + " TblTre.Tenthuonggoi, "
 + " TblTre.Gioitinh, "
 + " TblTre.Ngaysinh "
 + " FROM "
 + " 	TblNamtrehoc "
 + " inner join TblTre on TblTre.Id = TblNamtrehoc.TreId "
 + " where (TblNamtrehoc.Tinhtrang =0 and TblNamtrehoc.NamhocId =? ) "
 + " ORDER BY TblTre.ten "
 + " else "
 + " SELECT "
 + " 	TblNamtrehoc.Id, "
 + " 	TblNamtrehoc.TreId, "
 + " 	TblNamtrehoc.LophocId, "
 + " 	TblNamtrehoc.NamhocId, "
 + " 	TblNamtrehoc.Tinhtrang, "
 + " TblTre.Hovaten,  "
 + " TblTre.Tenthuonggoi, "
 + " TblTre.Gioitinh, "
 + " TblTre.Ngaysinh "
 + " FROM TblNamtrehoc "
 + " inner join TblTre on TblTre.Id = TblNamtrehoc.TreId "
 + " where (TblNamtrehoc.Tinhtrang =0 and TblNamtrehoc.NamhocId =? and TblNamtrehoc.LophocId =@LophocId) "
 + " ORDER BY TblTre.ten ";
        public static string SPROC_TBLNAMTREHOC_GETBYFIND = "SELECT      TblNamtrehoc.Id, TblNamtrehoc.TreId, TblNamtrehoc.LophocId, TblNamtrehoc.NamhocId, "
 + "                       TblNamtrehoc.Tinhtrang, TblTre.Hovaten, TblTre.Tenthuonggoi, TblTre.Gioitinh, TblTre.Ngaysinh "
 + " FROM         TblNamtrehoc INNER JOIN "
 + "                       TblTre ON TblTre.Id = TblNamtrehoc.TreId "
 + " WHERE     (TblNamtrehoc.Tinhtrang = 0) AND (TblNamtrehoc.NamhocId = ?) AND (TblNamtrehoc.LophocId = @LophocId) AND  "
 + "                       (TblTre.Hovaten like '%'+ @Hovaten + '%') AND (TblTre.Tenthuonggoi like '%'+ @Tenthuonggoi + '%') AND (TblTre.Gioitinh like '%' +@Gioitinh+'%') "
 + " ORDER BY TblTre.Ten ";
        public static string SPROC_TBLNAMTREHOC_GETBYID = "SELECT"
 + " 	TblNamtrehoc.Id, "
 + " 	TblNamtrehoc.TreId, "
 + " 	TblNamtrehoc.LophocId, "
 + " 	TblNamtrehoc.NamhocId, "
 + " 	TblNamtrehoc.Tinhtrang, "
 + " TblTre.Hovaten, TblTre.Tenthuonggoi "
 + " FROM TblNamtrehoc inner join TblTre on TblNamtrehoc.TreId = TblTre.Id "
 + " WHERE 	TblNamtrehoc.Id = ? and TblNamtrehoc.Tinhtrang = 0 ";
        public static string SPROC_TBLNAMTREHOC_GETBYNAMHOCID = "SELECT * FROM TblNamtrehoc WHERE TblNamtrehoc.NamhocId = ? and TblNamtrehoc.Tinhtrang = 0 ";
        public static string SPROC_TBLNAMTREHOC_GETBYNAMTREHOCID = "SELECT"
 + " 	TblNamtrehoc.Id, "
 + " 	TblNamtrehoc.TreId, "
 + " 	TblNamtrehoc.LophocId, "
 + " 	TblNamtrehoc.NamhocId, "
 + " 	TblNamtrehoc.Tinhtrang, "
 + " TblTre.Hovaten,  "
 + " TblTre.Tenthuonggoi, "
 + " TblTre.Gioitinh, "
 + " TblTre.Ngaysinh "
 + " FROM TblNamtrehoc inner join TblTre on TblTre.Id = TblNamtrehoc.TreId "
 + " where TblNamtrehoc.Tinhtrang =0 and TblNamtrehoc.Id = @NamtrehocId and TblNamtrehoc.LophocId = @LophocId and TblNamtrehoc.NamhocId = @NamhocId "
 + " ORDER BY TblTre.ten ";
        public static string SPROC_TBLNAMTREHOC_GETCOUNT = "SELECT COUNT(*) FROM TblNamtrehoc where Tinhtrang = 0 and NamhocId = ? ";
        public static string SPROC_TBLNAMTREHOC_UPDATE = "UPDATE TblNamtrehoc SET LophocId = @LophocId WHERE Id = @Id ";
        public static string SPROC_TBLNAMTREHOC_UPDATETINHTRANG = "UPDATE TblNamtrehoc SET Tinhtrang = ?, LophocId = ? WHERE Id =?";
        public static string SPROC_TBLNHANVIEN_ADD = "	INSERT INTO TblNhanvien" +
           "([Hotendem],[Ten],[Namsinh],[Gioitinh],[CMND],[Noicap],[Ngaycap],[Tpbanthan],[Tpgiadinh],[Quequan],[Noiohientai],[DantocId],[DatchuanId],[TongiaoId],[Email],[Dienthoai],[QuoctichId],[UutienId],[Trangthai],[Note],[Ngayvaodoan],[Ngayvaodang],[HedaotaoId],[DiemtruongId])" +
     " VALUES('@Hotendem','@Ten',#@Namsinh#,'@Gioitinh','@CMND','@Noicap',#@Ngaycap#,'@Tpbanthan','@Tpgiadinh','@Quequan' ,'@Noiohientai','@DantocId','@DatchuanId','@TongiaoId','@Email','@Dienthoai','@QuoctichId','@UutienId','0'          ,'@Note','@Ngayvaodoan','@Ngayvaodang',@HedaotaoId, @DiemtruongId)";
        public static string SPROC_TBLNHANVIEN_DEL = "delete from TblNhanvien where (Id = @Id) ";
        public static string SPROC_TBLNHANVIEN_GET = "SELECT TblNhanvien.Id, TblNhanvien.Hotendem, TblNhanvien.Ten, TblNhanvien.Namsinh, TblNhanvien.Gioitinh, TblNhanvien.CMND, TblNhanvien.Noicap, TblNhanvien.Ngaycap, TblNhanvien.Tpbanthan, TblNhanvien.Tpgiadinh, TblNhanvien.Quequan, TblNhanvien.Noiohientai, TblDm_Hedaotao.Tenhedaotao, TblNhanvien.DantocId, TblNhanvien.DatchuanId, TblNhanvien.TongiaoId, TblNhanvien.Email, TblNhanvien.Dienthoai, TblNhanvien.QuoctichId, TblNhanvien.UutienId, TblDm_Tongiao.Tentongiao, TblDm_Quoctich.Tenquoctich, TblDm_Datchuan.Tendatchuan, TblDm_Uutien.Tenuutien, TblDm_Dantoc.Tendantoc, TblNhanvien.Note, TblNhanvien.Ngayvaodoan, TblNhanvien.Ngayvaodang, TblNhanvien.HedaotaoId " +
" FROM TblDm_Hedaotao INNER JOIN (((((TblNhanvien INNER JOIN TblDm_Tongiao ON TblNhanvien.TongiaoId = TblDm_Tongiao.Id) INNER JOIN TblDm_Quoctich ON TblNhanvien.QuoctichId = TblDm_Quoctich.Id) INNER JOIN TblDm_Datchuan ON TblNhanvien.DatchuanId = TblDm_Datchuan.Id) INNER JOIN TblDm_Uutien ON TblNhanvien.UutienId = TblDm_Uutien.Id) INNER JOIN TblDm_Dantoc ON TblNhanvien.DantocId = TblDm_Dantoc.Id) ON TblDm_Hedaotao.Id = TblNhanvien.HedaotaoId " +
" ORDER BY TblNhanvien.Ten ";
        public static string SPROC_TBLNHANVIEN_GETBINCBONHANVIEN_CONGTAC = "SELECT"
 + " 	TblNhanvien.Id, "
 + " 	TblNhanvien.Hotendem, "
 + " 	TblNhanvien.Ten, "
 + " 	TblNhanvien.Trangthai, "
 + " 	TblNhanviencongtac.NhanvienId "
 + " FROM TblNhanvien left join TblNhanviencongtac on ( TblNhanvien.Id = TblNhanviencongtac.NhanvienId and "
 + " TblNhanviencongtac.NamhocId = ? and TblNhanvien.Trangthai = 0) ";
        // =-1
        public static string SPROC_TBLNHANVIEN_GETBYID1 = "SELECT * FROM TblNhanvien  ";
        // else

        public static string SPROC_TBLNHANVIEN_GETBYID2 = "SELECT * FROM TblNhanvien where Id = ? ";
        public static string SPROC_TBLNHANVIEN_GETBYID = "SELECT * FROM TblNhanvien where Id = ? ";
        //public static string SPROC_TBLNHANVIEN_GETBYIDTREE = ""
        //    + " if(@Id =-1 and '@Varname' = '')"
        //    + " 		SELECT Id, Hotendem, Ten FROM TblNhanvien where trangthai = 0 ORDER BY Ten "
        //    + " if(@Id =-1 and '@Varname' != '') "
        //    + " 		SELECT Id, Hotendem, Ten FROM TblNhanvien WHERE (Hotendem  + ' ' + Ten like '%' +'@Varname'+ '%') and trangthai =0 ORDER BY Ten "
        //    + " if(@Id !=-1) "
        //    + " 		SELECT Id, Hotendem, Ten FROM TblNhanvien WHERE Id =@Id and trangthai =0 ORDER BY Ten ";

        public static string SPROC_TBLNHANVIEN_GETBYIDTREE = ""
 + " if(@Id !=-1) begin "
 + " 		SELECT Id, Hotendem, Ten FROM TblNhanvien WHERE Id =@Id and trangthai =0 ORDER BY Ten  end"
 + " else  begin "
 + "       SELECT Id, Hotendem, Ten FROM TblNhanvien WHERE (Hotendem  + ' ' + Ten like '%' +'@Varname'+ '%') and trangthai =0 ORDER BY Ten          end";

        //if @Id ==-1
        public static string SPROC_TBLNHANVIEN_GETBYIDTREE1 = ""

           + "       SELECT Id, Hotendem, Ten FROM TblNhanvien WHERE (Hotendem  + ' ' + Ten like '%' +'@Varname'+ '%') and trangthai =0 ORDER BY Ten          ";
        //@Id !=-1
        public static string SPROC_TBLNHANVIEN_GETBYIDTREE2 = ""

           + " 		SELECT Id, Hotendem, Ten FROM TblNhanvien WHERE Id =@Id and trangthai =0 ORDER BY Ten  ";

        public static string SPROC_TBLNHANVIEN_GETFIND = "SELECT  TblNhanvien.Id, TblNhanvien.Hotendem, TblNhanvien.Ten, TblNhanvien.Namsinh, TblNhanvien.Gioitinh, "
 + " TblNhanvien.CMND, TblNhanvien.Noicap, TblNhanvien.Ngaycap, TblNhanvien.Tpbanthan, TblNhanvien.Tpgiadinh,  "
 + " TblNhanvien.Quequan, TblNhanvien.Noiohientai, TblNhanvien.DantocId, TblNhanvien.DatchuanId, TblNhanvien.TongiaoId,  "
 + " TblNhanvien.Email, TblNhanvien.Dienthoai, TblNhanvien.QuoctichId, TblNhanvien.UutienId, TblDm_Tongiao.Tentongiao,  "
 + " TblDm_Quoctich.Tenquoctich, TblDm_Datchuan.Tendatchuan, TblDm_Uutien.Tenuutien, TblDm_Dantoc.Tendantoc "
 + " FROM ((((TblNhanvien INNER JOIN "
 + "  TblDm_Tongiao ON TblNhanvien.TongiaoId = TblDm_Tongiao.Id) INNER JOIN "
 + "  TblDm_Quoctich ON TblNhanvien.QuoctichId = TblDm_Quoctich.Id) INNER JOIN "
 + "  TblDm_Datchuan ON TblNhanvien.DatchuanId = TblDm_Datchuan.Id) INNER JOIN "
 + "  TblDm_Uutien ON TblNhanvien.UutienId = TblDm_Uutien.Id) INNER JOIN "
 + "  TblDm_Dantoc ON TblNhanvien.DantocId = TblDm_Dantoc.Id "
 + " WHERE 1 = 1";
        public static string Sproc_TblNhanvienGetFind = "SELECT TblNhanvien.Id, TblNhanvien.Hotendem, TblNhanvien.Ten, TblNhanvien.Namsinh, TblNhanvien.Gioitinh, TblNhanvien.CMND, TblNhanvien.Noicap, TblNhanvien.Ngaycap, TblNhanvien.Tpbanthan, TblNhanvien.Tpgiadinh, TblNhanvien.Quequan, TblNhanvien.Noiohientai, TblDm_Hedaotao.Tenhedaotao, TblNhanvien.DantocId, TblNhanvien.DatchuanId, TblNhanvien.TongiaoId, TblNhanvien.Email, TblNhanvien.Dienthoai, TblNhanvien.QuoctichId, TblNhanvien.UutienId, TblDm_Tongiao.Tentongiao, TblDm_Quoctich.Tenquoctich, TblDm_Datchuan.Tendatchuan, TblDm_Uutien.Tenuutien, TblDm_Dantoc.Tendantoc, TblNhanvien.Ngayvaodoan, TblNhanvien.Ngayvaodang, TblNhanvien.HedaotaoId" +
" FROM TblDm_Hedaotao INNER JOIN (((((TblNhanvien INNER JOIN TblDm_Tongiao ON TblNhanvien.TongiaoId = TblDm_Tongiao.Id) INNER JOIN TblDm_Quoctich ON TblNhanvien.QuoctichId = TblDm_Quoctich.Id) INNER JOIN TblDm_Datchuan ON TblNhanvien.DatchuanId = TblDm_Datchuan.Id) INNER JOIN TblDm_Uutien ON TblNhanvien.UutienId = TblDm_Uutien.Id) INNER JOIN TblDm_Dantoc ON TblNhanvien.DantocId = TblDm_Dantoc.Id) ON TblDm_Hedaotao.Id = TblNhanvien.HedaotaoId " +
" WHERE (((TblNhanvien.Gioitinh) Like '%'+'@Gioitinh'+'%') AND ((TblNhanvien.Quequan) Like '%'+'@Quequan'+'%') AND ((TblNhanvien.Noiohientai) Like '%'+'@Noiohientai'+'%') AND ((TblDm_Tongiao.Tentongiao) Like '%'+'@Tentongiao'+'%') AND ((TblDm_Datchuan.Tendatchuan) Like '%'+'@Tendatchuan'+'%') AND ((TblDm_Uutien.Tenuutien) Like '%'+'@Tenuutien'+'%') AND ((TblDm_Dantoc.Tendantoc) Like '%'+'@Tendantoc'+'%') AND (([TblNhanvien].[Hotendem]+' '+[TblNhanvien].[Ten]) Like '%'+'@Hotendem'+'%')) " +
" ORDER BY TblNhanvien.Ten";
        public static string SPROC_TBLNHANVIEN_GIADINH_ADD = "INSERT INTO TblNhanvien_giadinh (NhanvienId, Hoten, Namsinh, Nghenghiep, QuanheId) VALUES( ?, ?, ?, ?, ?)";
        public static string SPROC_TBLNHANVIEN_GIADINH_DELETE = "DELETE FROM TblNhanvien_giadinh WHERE Id = ? ";
        public static string SPROC_TBLNHANVIEN_GIADINH_GET = "SELECT"
 + " 	TblNhanvien_giadinh.Id, TblNhanvien_giadinh.NhanvienId, TblNhanvien_giadinh.Hoten, "
 + " TblNhanvien_giadinh.Namsinh, TblNhanvien_giadinh.Nghenghiep, TblNhanvien_giadinh.QuanheId, "
 + " TblDm_Quanhe.Tenquanhe "
 + " FROM TblNhanvien_giadinh "
 + " inner join TblDm_Quanhe on TblDm_Quanhe.Id = TblNhanvien_giadinh.QuanheId "
 + " where (NhanvienId =?) ";
        public static string SPROC_TBLNHANVIEN_GIADINH_UPDATE = "UPDATE TblNhanvien_giadinh SET NhanvienId = @NhanvienId, Hoten = \"@Hoten\", Namsinh = @Namsinh, Nghenghiep = \"@Nghenghiep\", QuanheId = @QuanheId WHERE Id =@Id";
        public static string SPROC_TBLNHANVIEN_GIADINHBYQUANHEID = "SELECT NhanvienId, Hoten, Namsinh, Nghenghiep, QuanheId FROM TblNhanvien_giadinh WHERE QuanheId = ? ";
        public static string SPROC_TBLNHANVIEN_KHENTHUONGKYLUAT_ADD = "	INSERT INTO TblNhanvien_Khenthuongkyluat (NhanviencongtacId, Loaihinhthuc, Hinhthuc, Ngay, Ghichu) VALUES (?, ?, ?, ?, ? )";
        public static string SPROC_TBLNHANVIEN_KHENTHUONGKYLUAT_DELETE = "DELETE"
 + " FROM TblNhanvien_Khenthuongkyluat "
 + " WHERE Id =?"
;
        public static string SPROC_TBLNHANVIEN_KHENTHUONGKYLUAT_GET = "SELECT"
 + " * "
 + " FROM TblNhanvien_Khenthuongkyluat "
  + " where (NhanviencongtacId =@NhanviencongtacId)  "
            //+ " where (NhanviencongtacId =@NhanviencongtacId) and Loaihinhthuc like '%' +@Loaihinhthuc+ '%' "
;
        public static string SPROC_TBLNHANVIEN_KHENTHUONGKYLUAT_UPDATE = "UPDATE TblNhanvien_Khenthuongkyluat"
 + " SET NhanviencongtacId = @NhanviencongtacId, "
 + " 	Loaihinhthuc = '@Loaihinhthuc', "
 + " 	Hinhthuc = '@Hinhthuc', "
 + " 	Ngay = '@Ngay', "
 + " 	Ghichu = '@Ghichu' "
 + " WHERE Id = @Id";
        public static string SPROC_TBLNHANVIEN_UPDATE = "UPDATE [TblNhanvien] " +
   " SET [Hotendem] = '@Hotendem',[Ten] = '@Ten',[Namsinh] = #@Namsinh#,[Gioitinh] = '@Gioitinh',[CMND] = '@CMND',[Noicap] = '@Noicap',[Ngaycap] = '@Ngaycap',[Tpbanthan] = 'Tpbanthan' ,[Tpgiadinh] = '@Tpgiadinh'" +
      ",[Quequan] = '@Quequan' ,[Noiohientai] = '@Noiohientai',[DantocId] = '@DantocId'," +
      "[DatchuanId] = '@DatchuanId',[TongiaoId] = '@TongiaoId',[Email] = '@Email' ," +
      "[Dienthoai] = '@Dienthoai',[QuoctichId] = '@QuoctichId',[UutienId] = '@UutienId'," +
      "[Note] = '@Note',[Ngayvaodoan] ='@Ngayvaodoan', [Ngayvaodang] ='@Ngayvaodang', " +
      "[HedaotaoId] =@HedaotaoId WHERE (Id =@Id)";
        public static string SPROC_TBLNHANVIEN_UPDATETRANGTHAIBYID = "update TblNhanvien set Trangthai = ? where (Id = ?) ";
        public static string SPROC_TBLNHANVIENCONGTAC_ADD = "INSERT INTO TblNhanviencongtac"
 + " 	( 	NhanvienId, "
 + " 		ToId, "
 + " 		ChucvuId, "
 + " 		Tungay, "
 + " 		Denngay, "
 + " 		NamhocId, "
 + " 		Motatrangthai ) "
 + " 	VALUES ( ?, ?, ?, ?, ?, ?, ? ) ";
        public static string SPROC_TBLNHANVIENCONGTAC_BYCHUCVUID = "SELECT     Id, NhanvienId, ToId, ChucvuId, Tungay, Denngay, NamhocId, Motatrangthai"
 + " FROM         TblNhanviencongtac "
 + " WHERE     (ChucvuId = ?) ";
        public static string SPROC_TBLNHANVIENCONGTAC_DEL = "delete from TblNhanviencongtac where (Id = ?) ";
        public static string SPROC_TBLNHANVIENCONGTAC_DELETE = "DELETE FROM TblNhanviencongtac WHERE Id = ? and NamhocId = ? ";
        public static string SPROC_TBLNHANVIENCONGTAC_FIND = "SELECT"
 + " 	TblNhanviencongtac.Id, "
 + " 	TblNhanviencongtac.NhanvienId, "
 + " 	TblNhanviencongtac.ToId, "
 + " 	TblNhanviencongtac.ChucvuId, "
 + " 	TblNhanviencongtac.Tungay, "
 + " 	TblNhanviencongtac.Denngay, "
 + " 	TblNhanviencongtac.NamhocId, "
 + " 	TblNhanviencongtac.Motatrangthai, "
 + "             TblNhanvien.Hotendem,  "
 + "           TblNhanvien.ten, "
 + "             TblNhanvien.Namsinh, "
 + "             TblNhanvien.gioitinh,  "
 + "            TblNhanvien.CMND,  "
 + "               TblNhanvien.Noiohientai,  "
 + "                 TblDm_chucvu.Tenchucvu, "
 + "                 TblDm_to.Tento "
 + " FROM	((TblNhanviencongtac "
 + " inner join TblNhanvien on TblNhanvien.Id = TblNhanviencongtac.NhanvienId) "
 + " inner join TblDm_chucvu on TblNhanviencongtac.ChucvuId = TblDm_Chucvu.Id) "
 + " inner join TblDm_To on TblDm_to.Id = TblNhanviencongtac.ToId "
 + " where (NamhocId =@NamhocId and Motatrangthai = '@Motatrangthai'  ) "
 + " and (TblNhanvien.Hotendem + ' ' + TblNhanvien.ten like '%@Hotendem%'  ) "
 + " and TblNhanvien.Gioitinh like '%@Gioitinh%' "
 + " ORDER BY TblNhanvien.Ten ";
        public static string SPROC_TBLNHANVIENCONGTAC_GETBYID = "SELECT * FROM TblNhanviencongtac WHERE Id =? and (NamhocId = ?) ";
        // =-1
        public static string SPROC_TBLNHANVIENCONGTAC_GETBYIDTREE1 = "SELECT  TblNhanviencongtac.Id,  TblNhanviencongtac.NhanvienId, TblNhanviencongtac.ToId, TblNhanviencongtac.ChucvuId, TblNhanviencongtac.Tungay, TblNhanviencongtac.Denngay,  TblNhanviencongtac.NamhocId, TblNhanviencongtac.Motatrangthai,  TblNhanvien.Hotendem,   TblNhanvien.ten,  TblNhanvien.Namsinh,  TblNhanvien.gioitinh,   TblNhanvien.CMND,   TblNhanvien.Noiohientai,   TblDm_chucvu.Tenchucvu,  TblDm_to.Tento  FROM ((TblNhanviencongtac  inner join TblNhanvien on TblNhanvien.Id = TblNhanviencongtac.NhanvienId)   inner join TblDm_chucvu on TblNhanviencongtac.ChucvuId = TblDm_Chucvu.Id)  inner join TblDm_To on TblDm_to.Id = TblNhanviencongtac.ToId  where (NamhocId =@NamhocId and Motatrangthai = '@Motatrangthai'   and TblNhanvien.Hotendem like '%' +'@Hotendem'+'%' )   or ( NamhocId =@NamhocId and Motatrangthai = '@Motatrangthai' and  TblNhanvien.ten like '%'+'@Ten'+ '%') ";

        //!=-1   
        public static string SPROC_TBLNHANVIENCONGTAC_GETBYIDTREE2 = "SELECT TblNhanviencongtac.Id,  TblNhanviencongtac.NhanvienId,  TblNhanviencongtac.ToId,  TblNhanviencongtac.ChucvuId,  TblNhanviencongtac.Tungay,  TblNhanviencongtac.Denngay,  TblNhanviencongtac.NamhocId,  TblNhanviencongtac.Motatrangthai,  TblNhanvien.Hotendem,   TblNhanvien.ten,  TblNhanvien.Namsinh,  TblNhanvien.gioitinh,   TblNhanvien.CMND,   TblNhanvien.Noiohientai,   TblDm_chucvu.Tenchucvu,  TblDm_to.Tento  FROM ((TblNhanviencongtac  inner join TblNhanvien on TblNhanvien.Id = TblNhanviencongtac.NhanvienId)  inner join TblDm_chucvu on TblNhanviencongtac.ChucvuId = TblDm_Chucvu.Id ) inner join TblDm_To on TblDm_to.Id = TblNhanviencongtac.ToId  where ( NamhocId =@NamhocId and Motatrangthai = '@Motatrangthai' and  TblNhanvien.Id =@NhanvienId) ";
        public static string SPROC_TBLNHANVIENCONGTAC_GETBYNAMHOCID = "SELECT     Id, NhanvienId, Tungay, ChucvuId, ToId, Denngay, NamhocId, Motatrangthai"
 + " FROM         TblNhanviencongtac "
 + " WHERE     (NamhocId = ?) ";
        public static string SPROC_TBLNHANVIENCONGTAC_GETBYNAMHOCIDANDMOTATRANGTHAI = "SELECT     Id, NhanvienId, Tungay, ChucvuId, ToId, Denngay, NamhocId, Motatrangthai"
 + " FROM         TblNhanviencongtac "
 + " WHERE     (NamhocId = ?) AND (Motatrangthai LIKE '%?%') ";
        public static string SPROC_TBLNHANVIENCONGTAC_GETLISTVIEW = "SELECT"
 + " 	TblNhanviencongtac.Id, "
 + " 	TblNhanviencongtac.NhanvienId, "
 + " 	TblNhanviencongtac.ToId, "
 + " 	TblNhanviencongtac.ChucvuId,	 "
 + " 	TblNhanviencongtac.NamhocId,        "
 + "     TblNhanvien.Hotendem,  "
 + " 	TblNhanvien.ten, "
 + "     TblNhanvien.Namsinh, "
 + "     TblNhanvien.gioitinh,  "
 + " 	TblNhanvien.CMND,  "
 + "     TblNhanvien.Noiohientai, "
 + "     TblDm_to.Tento, "
 + "     TblDm_chucvu.Tenchucvu, "
 + " 	TblNhanviencongtac.Tungay, "
 + " 	TblNhanviencongtac.Denngay, "
 + " 	TblNhanviencongtac.Motatrangthai "
 + " FROM	((TblNhanviencongtac "
 + " inner join TblNhanvien on TblNhanvien.Id = TblNhanviencongtac.NhanvienId) "
 + " inner join TblDm_chucvu on TblNhanviencongtac.ChucvuId = TblDm_Chucvu.Id) "
 + " inner join TblDm_To on TblDm_to.Id = TblNhanviencongtac.ToId "
 + " where (NamhocId = ? and Motatrangthai = ?) "
 + " ORDER BY TblNhanvien.Ten ";
        public static string SPROC_TBLNHANVIENCONGTAC_TO_GETLISTVIEW = "SELECT"
 + " 	TblNhanviencongtac.Id, "
 + " 	TblNhanviencongtac.NhanvienId, "
 + " 	TblNhanviencongtac.ToId, "
 + " 	TblNhanviencongtac.ChucvuId, "
 + " 	TblNhanviencongtac.NamhocId, "
 + "             TblNhanvien.Hotendem,  "
 + "           TblNhanvien.ten, "
 + "             TblNhanvien.Namsinh, "
 + "             TblNhanvien.gioitinh,  "
 + "               TblNhanvien.Noiohientai,  "
 + "                 TblDm_chucvu.Tenchucvu, "
 + "                 TblDm_to.Tento "
 + " FROM	((TblNhanviencongtac "
 + " inner join TblNhanvien on TblNhanvien.Id = TblNhanviencongtac.NhanvienId) "
 + " inner join TblDm_chucvu on TblNhanviencongtac.ChucvuId = TblDm_Chucvu.Id) "
 + " inner join TblDm_To on TblDm_to.Id = TblNhanviencongtac.ToId "
 + " where NamhocId=?  and TblNhanviencongtac.ToId=? and TblNhanvien.Trangthai =0 ";
        public static string SPROC_TBLNHANVIENCONGTAC_UPDATE = "UPDATE TblNhanviencongtac"
 + " SET	NhanvienId = @NhanvienId, "
 + " 	ToId =@ToId , "
 + " 	ChucvuId = @ChucvuId, "
 + " 	Tungay = '@Tungay', "
 + " 	Denngay = '@Denngay', "
 + " 	NamhocId = @NamhocId, "
 + " 	Motatrangthai = '@Motatrangthai' "
 + " WHERE Id = @Id";
        public static string SPROC_TBLNHANVIENCONGTAC_UPDATETOID = "UPDATE TblNhanviencongtac"
 + " SET ToId = @ToId "
 + " WHERE Id =@Id";
        public static string SPROC_TBLNHANVIENDAOTAO_ADD = "	INSERT INTO TblNhanviendaotao"
 + " 	( 	NhanviencongtacId, "
 + " 		Namnhaphoc, "
 + " 		Namtotnghiep, "
 + " 		Noidaotao, "
 + " 		Nganhdaotao, "
 + " 		Ketquadaotao, "
 + " 		Ghichu ) VALUES ( ?, ?, ?, ?, ?, ?, ? ) ";
        public static string SPROC_TBLNHANVIENDAOTAO_DELETE = "DELETE"
 + " FROM TblNhanviendaotao "
 + " WHERE Id =?";
        public static string SPROC_TBLNHANVIENDAOTAO_GET = "SELECT"
 + " * "
 + " FROM TblNhanviendaotao "
 + " where (NhanviencongtacId = ?) ";
        public static string SPROC_TBLNHANVIENDAOTAO_UPDATE = "UPDATE TblNhanviendaotao"
 + " SET "
 + " 	Namnhaphoc = '@Namnhaphoc', "
 + " 	Namtotnghiep = '@Namtotnghiep', "
 + " 	Noidaotao = '@Noidaotao', "
 + " 	Nganhdaotao = '@Nganhdaotao', "
 + " 	Ketquadaotao = '@Ketquadaotao', "
 + " 	Ghichu = '@Ghichu' "
 + " WHERE Id =@Id";
        public static string SPROC_TBLNHAPXUATHANGHOA_ADD = "	INSERT INTO TblNhapxuathanghoa"
 + " 	( 	HoadonnhapxuatId, "
 + " 		DonvitinhId, "
 + " 		Thucpham_ThucanId, "
 + " 		Soluong, "
 + " 		Dongia, "
 + " 		Soluongcon "
 + " 	) "
 + " 	VALUES "
 + " 	( ?, ?, ?, ?, ?, ?) ";
        public static string SPROC_TBLPHIEUTIENAN_DEL = "delete from TblPhieutienan"
 + "            where (Id =@Id) ";
        public static string SPROC_TBLPHIEUTIENAN_DELBYNAMHOCID = "delete TblPhieutienan"
 + "            where (Id in (SELECT TblPhieutienan.Id "
 + " FROM         TblPhieutienan INNER JOIN TblNamtrehoc ON TblPhieutienan.NamtrehocId = TblNamtrehoc.Id "
 + " WHERE     (TblNamtrehoc.NamhocId = ?))) ";
        public static string SPROC_TBLPHIEUTIENAN_INSERT = "INSERT INTO TblPhieutienan("
 + "            Sobienlai "
 + "            ,NamtrehocId "
 + "            ,Ngaymua "
 + "            ,ThanghocId "
 + "            ,Tongsophieumua "
 + "            ,Tongsophieudoi "
 + "            ,Dongia "
 + "            ,Ghichu) "
 + "      VALUES (@Sobienlai, @NamtrehocId, @Ngaymua, @ThanghocId, @Tongsophieumua, @Tongsophieudoi, @Dongia, @Ghichu) ";
        public static string SPROC_TBLPHIEUTIENAN_SELECTALLBYNAMHOCID = "SELECT     TblPhieutienan.Id, TblPhieutienan.Ngaymua, TblPhieutienan.Sobienlai, TblTre.Hovaten, TblNamtrehoc.LophocId, "
 + "                       TblPhieutienan.NamtrehocId, TblPhieutienan.ThanghocId, TblLop.Tenlop, TblPhieutienan.Tongsophieumua,  "
 + "                       TblPhieutienan.Dongia, TblPhieutienan.Tongsophieudoi "
 + " FROM         TblPhieutienan INNER JOIN "
 + "                       TblNamtrehoc ON TblPhieutienan.NamtrehocId = TblNamtrehoc.Id INNER JOIN "
 + "                       TblLop ON TblNamtrehoc.LophocId = TblLop.Id INNER JOIN "
 + "                       TblTre ON TblNamtrehoc.TreId = TblTre.Id "
 + " WHERE     (TblNamtrehoc.NamhocId = ?) AND (TblPhieutienan.ThanghocId = ?) ";
        public static string SPROC_TBLPHIEUTIENAN_SELECTALLBYSOBIENLAI = "SELECT     Id, Sobienlai"
 + " FROM         TblPhieutienan "
 + " WHERE     (Sobienlai = ?) ";
        public static string SPROC_TBLPHIEUTIENAN_SELECTALLBYTHANG_LOP_GIOITINH = "SELECT     TblPhieutienan.Id, TblPhieutienan.Ngaymua, TblPhieutienan.Sobienlai, TblTre.Hovaten, TblNamtrehoc.LophocId, "
 + "                       TblPhieutienan.NamtrehocId, TblPhieutienan.ThanghocId, TblLop.Tenlop, TblPhieutienan.Tongsophieumua,  "
 + "                       TblPhieutienan.Dongia, TblPhieutienan.Tongsophieudoi "
 + " FROM         TblPhieutienan INNER JOIN "
 + "                       TblNamtrehoc ON TblPhieutienan.NamtrehocId = TblNamtrehoc.Id INNER JOIN "
 + "                       TblLop ON TblNamtrehoc.LophocId = TblLop.Id INNER JOIN "
 + "                       TblTre ON TblNamtrehoc.TreId = TblTre.Id "
 + " WHERE     (TblNamtrehoc.NamhocId = ?) AND (TblPhieutienan.ThanghocId = ?) AND (TblLop.Tenlop LIKE '%' + @Tenlop + '%')  "
 + "                       AND (TblTre.Gioitinh LIKE '%' + @Gioitinh + '%') AND (TblTre.Hovaten LIKE '%' + @Tenhocsinh + '%') ";
        public static string SPROC_TBLPHIEUTIENAN_UPDATE = "UPDATE TblPhieutienan"
 + " SET Sobienlai = '@Sobienlai', "
 + " 	NamtrehocId = @NamtrehocId, "
 + " 	Ngaymua = @Ngaymua, "
 + " 	ThanghocId = @ThanghocId, "
 + " 	Tongsophieumua = @Tongsophieumua, "
 + " 	Tongsophieudoi = @Tongsophieudoi, "
 + " 	Dongia = @Dongia, "
 + " 	Ghichu = '@Ghichu' "
 + " WHERE Id =@Id";
        public static string SPROC_TBLPHONGHOC_ADD = "	INSERT INTO TblPhonghoc ( LoaiphonghocId,DiemtruongId,CapxaydungId, Tenphong,dientich,trangthai, duthietbi,xaymoi,namhocId ) VALUES (@LoaiphonghocId, @DiemtruongId, @CapxaydungId,'@Tenphong',@Dientich,'@trangthai',@duthietbi,@xaymoi,select Id from TblDm_namhoc where trangthai=-1 )";
        public static string SPROC_TBLPHONGHOC_DELETE = "DELETE FROM TblPhonghoc WHERE Id =?";
        public static string SPROC_TBLPHONGHOC_GET = "SELECT"
 + " 	TblPhonghoc.Id, TblPhonghoc.LoaiphonghocId, TblPhonghoc.DiemtruongId, TblPhonghoc.CapxaydungId, TblPhonghoc.Tenphong,TblPhonghoc.Dientich,TblPhonghoc.Trangthai,TblPhonghoc.Duthietbi,TblPhonghoc.xaymoi, TblDiemtruong.Tendiem, "
 + " TblDm_Capxaydung.Tencapxaydung, TblDm_Loaiphonghoc.Tenloaiphong FROM "
 + " 	((TblPhonghoc "
 + " inner join TblDiemtruong on TblDiemtruong.Id = TblPhonghoc.DiemtruongId)  "
 + " inner join TblDm_Capxaydung on TblDm_Capxaydung.Id =TblPhonghoc.CapxaydungId) "
 + " inner join TblDm_Loaiphonghoc on TblDm_Loaiphonghoc.Id = TblPhonghoc.LoaiphonghocId "
 + " ORDER BY TblPhonghoc.Tenphong ";
        public static string SPROC_TBLPHONGHOC_GETBYID = "SELECT * FROM TblPhonghoc WHERE Id =@Id";
        public static string SPROC_TBLPHONGHOC_GETBYLOAIPHONGHOCID = "SELECT * FROM TblPhonghoc WHERE LoaiphonghocId = @Id ";
        public static string SPROC_TBLPHONGHOC_UPDATE = "UPDATE TblPhonghoc SET LoaiphonghocId = @LoaiphonghocId,DiemtruongId = @DiemtruongId, CapxaydungId = @CapxaydungId, Tenphong = '@Tenphong',dientich=@dientich,trangthai='@trangthai',duthietbi = @duthietbi,xaymoi = @xaymoi  WHERE Id = @Id";
        public static string SPROC_TBLTEMP_ADD = "	INSERT INTO TblTemp"
 + " 	( 	DonvitinhId, "
 + " 		Thucpham_ThucanId, "
 + " 		Soluonglayxuat, "
 + " 		Soluong, "
 + " 		Dongia ) "
 + " 	VALUES ( ?, ?, ?, ?, ? ) ";
        public static string SPROC_TBLTEMP_DELETE = "DELETE FROM TblTemp";
        public static string SPROC_TBLTEMP_DELETEBYTHUCPHAM_THUCANID = "delete TblTemp where (TblTemp.Thucpham_thucanId = ? ) ";
        public static string SPROC_TBLTEMP_GET = "SELECT"
 + " 	HoadonnhapxuatId, "
 + " 	DonvitinhId, "
 + " 	Thucpham_ThucanId, "
 + " 	Soluonglayxuat, "
 + " 	Soluong, "
 + " 	Dongia "
 + " FROM TblTemp ";
        public static string SPROC_TBLTEMP_GETBYTHUCPHAM_THUCANID = "SELECT"
 + " * "
 + " FROM TblTemp "
 + " where (TblTemp.Thucpham_thucanId = ? ) ";
        public static string SPROC_TBLTHANNHANTRE_ADD = "	INSERT INTO TblThannhantre"
 + " 	( 	TreId, "
 + " 		Hoten, "
 + " 		QuanheId, "
 + " 		Namsinh, "
 + " 		Nghenghiep "
 + " 	) VALUES ( ?, ?, ?, ?, ?) ";
        public static string SPROC_TBLTHANNHANTRE_DELETE = "DELETE"
 + " FROM TblThannhantre "
 + " WHERE Id =?";
        public static string SPROC_TBLTHANNHANTRE_GETBYID = "SELECT"
 + "       TblThannhantre.Id, "
 + "          TblThannhantre.TreId, "
 + "         TblThannhantre.Hoten, "
 + "             TblThannhantre.QuanheId, "
 + " 	TblThannhantre.Namsinh, "
 + " 	TblThannhantre.Nghenghiep, TblDm_Quanhe.Tenquanhe "
 + " FROM TblThannhantre "
 + " inner join TblDm_Quanhe on TblDm_Quanhe.Id = TblThannhantre.QuanheId  "
 + " WHERE TblThannhantre.TreId =?";
        public static string SPROC_TBLTHANNHANTRE_UPDATE = "UPDATE TblThannhantre"
 + " SET TreId = ?, "
 + " 	Hoten = ?, "
 + " 	QuanheId = ?, "
 + " 	Namsinh = ?, "
 + " 	Nghenghiep = ? "
 + " WHERE Id =?";
        public static string SPROC_TBLTHONGTINXAHOI_ADD = "	INSERT INTO TblThongtinxahoi"
 + " 	( 	NhanvienId, "
 + " 		Tenthongtin, "
 + " 		Ngayvao, "
 + " 		Noiketnap, "
 + " 		Ngayvaochinhthuc, "
 + " 		Chucvucaonhat "
 + " 	) "
 + " 	VALUES ( ?, ?, ?, ?, ?, ?) ";
        public static string SPROC_TBLTHONGTINXAHOI_DELETE = "DELETE"
 + " FROM TblThongtinxahoi "
 + " WHERE Id =?";
        public static string SPROC_TBLTHONGTINXAHOI_GET = "SELECT"
 + " *,(select Tenchibo from TblDm_Chibo  where Id =TblThongtinxahoi.ChiboId) AS Tenchibo  "
 + " FROM TblThongtinxahoi "
 + " where(NhanvienId = ?) "
 + " ORDER BY Tenthongtin ";
        public static string SPROC_TBLTHONGTINXAHOI_UPDATE = "UPDATE TblThongtinxahoi"
 + " SET NhanvienId = @NhanvienId, "
 + " 	Tenthongtin =\"@Tenthongtin\" , "
 + " 	Ngayvao = \"@Ngayvao\", "
 + " 	Noiketnap = \"@Noiketnap\", "
 + " 	Ngayvaochinhthuc = \"@Ngaychinhthuc\", "
 + " 	Chucvucaonhat = \"@Chucvucaonhat\", ChiboId =@ChiboId "
 + " WHERE Id = @Id";
        public static string SPROC_TBLTHUCDON_MONAN_ADD = "	INSERT INTO TblThucdon_monan(ThuvienmonanId, Ngay, BuaantrongngayId, KhoilopId, NamhocId) VALUES (?,?,?,?,?) ";
        public static string SPROC_TBLTHUCDON_MONAN_BYBEGINNGAYENDNGAY = "SELECT      TblDm_Thuvienmonan.Tenmonan, TblDm_Khoilop.Tenkhoilop, TblDm_Buaantrongngay.Tenbuaan, "
 + "                       TblThucdon_monan.ThuvienmonanId, TblThucdon_monan.Ngay, TblThucdon_monan.BuaantrongngayId,  "
 + "                       TblThucdon_monan.KhoilopId "
 + " FROM         TblThucdon_monan INNER JOIN "
 + "                       TblDm_Khoilop ON TblThucdon_monan.KhoilopId = TblDm_Khoilop.Id INNER JOIN "
 + "                       TblDm_Thuvienmonan ON TblThucdon_monan.ThuvienmonanId = TblDm_Thuvienmonan.Id INNER JOIN "
 + "                       TblDm_Buaantrongngay ON TblThucdon_monan.BuaantrongngayId = TblDm_Buaantrongngay.Id "
 + " WHERE     (TblThucdon_monan.Ngay <= @EndNgay) and (TblThucdon_monan.Ngay >= @Begingay) ";
        public static string SPROC_TBLTHUCDON_MONAN_BYNGAY = "SELECT TblDm_Thuvienmonan.Tenmonan, TblDm_Khoilop.Tenkhoilop, TblDm_Buaantrongngay.Tenbuaan, "
 + "   TblThucdon_monan.ThuvienmonanId, TblThucdon_monan.Ngay, TblThucdon_monan.BuaantrongngayId, TblThucdon_monan.KhoilopId "
 + " FROM ((TblThucdon_monan INNER JOIN TblDm_Khoilop ON TblThucdon_monan.KhoilopId = TblDm_Khoilop.Id) "
 + "          INNER JOIN TblDm_Thuvienmonan ON TblThucdon_monan.ThuvienmonanId = TblDm_Thuvienmonan.Id) "
 + "          INNER JOIN TblDm_Buaantrongngay ON TblThucdon_monan.BuaantrongngayId = TblDm_Buaantrongngay.Id "
 + " WHERE TblThucdon_monan.Ngay = ? ";
        public static string SPROC_TBLTHUCDON_MONAN_BYNGAY_KHOILOPID_BUAANTRONGNGAYID = "SELECT     TblDm_Thuvienmonan.Tenmonan, TblDm_Khoilop.Tenkhoilop, TblDm_Buaantrongngay.Tenbuaan, "
 + "                       TblThucdon_monan.ThuvienmonanId, TblThucdon_monan.Ngay, TblThucdon_monan.BuaantrongngayId,  "
 + "                       TblThucdon_monan.KhoilopId "
 + " FROM         ((TblThucdon_monan INNER JOIN "
 + "                       TblDm_Thuvienmonan ON TblThucdon_monan.ThuvienmonanId = TblDm_Thuvienmonan.Id) INNER JOIN "
 + "                       TblDm_Khoilop ON TblThucdon_monan.KhoilopId = TblDm_Khoilop.Id) INNER JOIN "
 + "                       TblDm_Buaantrongngay ON TblThucdon_monan.BuaantrongngayId = TblDm_Buaantrongngay.Id "
 + " WHERE     (TblThucdon_monan.Ngay = ?) AND (TblThucdon_monan.KhoilopId = ?) AND (TblThucdon_monan.BuaantrongngayId = ?) ";
        public static string SPROC_TBLTHUCDON_MONAN_DEL_BYNGAY_KHOILOPID_BUAANTRONGNGAYID = "delete"
 + " FROM         TblThucdon_monan "
 + " WHERE     (Ngay = ?) AND (KhoilopId = ?) AND (BuaantrongngayId = ?) ";
        public static string SPROC_TBLTHUCDON_MONAN_DELETE = "DELETE"
 + " FROM TblThucdon_monan "
 + " WHERE Ngay = ? ";
        public static string SPROC_TBLTHUCDON_MONAN_DELETEBYNAMHOCID = "DELETE"
 + " FROM TblThucdon_monan "
 + " WHERE NamhocId = ? ";
        public static string SPROC_TBLTHUCPHAM_THUCAN_GETDONVITINHIDBYID = "SELECT"
 + " 	DonvitinhId "
 + " FROM TblThucpham_thucan "
 + " where(Id = ?) ";
        public static string SPROC_TBLTIENANCUATRE_GET = "";
        public static string SPROC_TBLTIENANTHUCTECHONGAY_GET = "";
        public static string SPROC_TBLTIENANTHUCTECHOTHANG_GET = "";
        public static string SPROC_TBLTRE_ADD = "INSERT INTO TblTre"
 + "( Hotendem, Ten, Hovaten, Tenthuonggoi, Ngaysinh, Noiohiennay, Gioitinh, Sodt, UutienId, Hotenbo, Nghenghiepbo, Hotenme, Nghengheme, Ghichu, Tinhtrang,DantocId) "
       + " 	VALUES ( '@Hotendem', '@Tenchinh','@Hovaten','@Tenthuonggoi', '@Ngaysinh', '@Noiohiennay', '@Gioitinh', '@Sodt', @UutienId, '@Hotenbo', '@Nghenghiepbo', '@Hotenme', '@Nghengheme','@Ghichu', '0',@DantocId) ";
        public static string SPROC_TBLTRE_ADDBYEXCEL = "INSERT INTO TblTre"
 + " 	(Hotendem, Ten, Hovaten, Tenthuonggoi, Ngaysinh, Noiohiennay, Gioitinh, Sodt, UutienId, Hotenbo, Nghenghiepbo, Hotenme, Nghengheme,  "
 + "                       Ghichu, Tinhtrang ) "
 + " 	VALUES( '@Hotendem', '@Ten', '@Hovaten', '@Tenthuonggoi', '@Ngaysinh', '@Noiohiennay', '@Gioitinh', '@Sodt', '@UutienId', '@Hotenbo', '@Nghenghiepbo', '@Hotenme', '@Nghengheme', '@Ghichu', '0' ); "
 + " 	INSERT INTO TblNamtrehoc "
 + " 	( 	TreId, "
 + " 		LophocId, "
 + " 		NamhocId, "
 + " 		Tinhtrang "
 + " 	) "
 + " SELECT max(Id)  FROM TblTre where TblTre.Tinhtrang = 0 , @LophocId, "
 + " 		@NamhocId, "
 + " 		@Tinhtrang ";
        public static string SPROC_TBLTRE_ADDBYEXCEL1 = " 	INSERT INTO TblNamtrehoc "
 + " 	( 	TreId, "
 + " 		LophocId, "
 + " 		NamhocId, "
 + " 		Tinhtrang "
 + " 	) "
 + " values( @TreId , @LophocId, "
 + " 		@NamhocId, "
 + " 		'0') ";
        public static string SPROC_TBLTRE_ADDBYEXCELRerumaxId2 = " SELECT max(Id)  FROM TblTre where TblTre.Tinhtrang = 0  ";
        public static string SPROC_TBLTRE_DELETE = "DELETE"
 + " FROM TblTre "
 + " WHERE Id =?";
        //public static string SPROC_TBLTRE_FIND = "if(@LophocId =-1)"
        //    + " SELECT  TblTre.Id, TblTre.Hovaten, TblTre.Hotendem, TblTre.Ten, TblTre.Tenthuonggoi, "
        //    + " 		TblTre.Ngaysinh, TblTre.Gioitinh, TblTre.Sodt, TblTre.Noiohiennay, TblTre.UutienId, "
        //    + " 		TblTre.Tinhtrang, TblTre.Hotenme, TblTre.Nghengheme, TblTre.Hotenbo, TblTre.Nghenghiepbo,  "
        //    + " 		TblNamtrehoc.Id AS NamtrehocId, TblTre.Ghichu "
        //    + " FROM  TblTre INNER JOIN "
        //    + "                       TblDm_Uutien ON TblDm_Uutien.Id = TblTre.UutienId INNER JOIN "
        //    + "                       TblNamtrehoc ON TblTre.Id = TblNamtrehoc.TreId "
        //    + " WHERE     (TblTre.Tinhtrang = 0) AND (TblTre.Hovaten LIKE '%' + @Hotendem + '%') AND (TblTre.Tenthuonggoi LIKE '%' + @Tenthuonggoi + '%') AND  "
        //    + "                       (TblDm_Uutien.Tenuutien LIKE '%' + @UutienId + '%') AND (TblTre.Noiohiennay LIKE '%' + @Noiohiennay + '%') AND  "
        //    + "                       (TblTre.Gioitinh LIKE '%' + @Gioitinh + '%') AND (TblNamtrehoc.NamhocId = ?) "
        //    + " ORDER BY TblTre.Ten "
        //    + " else "
        //    + " SELECT      TblTre.Id, TblTre.Hotendem, TblTre.Ten, TblTre.Hovaten, TblTre.Tenthuonggoi, TblTre.Ngaysinh,  "
        //    + "                       TblTre.Gioitinh, TblTre.Noiohiennay, TblTre.UutienId, TblTre.Sodt, TblTre.Tinhtrang,  TblTre.Hotenme,TblTre.Nghengheme,  "
        //    + "                       TblTre.Hotenbo,TblTre.Nghenghiepbo,  TblNamtrehoc.Id AS NamtrehocId, TblTre.Ghichu "
        //    + " FROM         TblTre INNER JOIN "
        //    + "                       TblDm_Uutien ON TblDm_Uutien.Id = TblTre.UutienId INNER JOIN "
        //    + "                       TblNamtrehoc ON TblTre.Id = TblNamtrehoc.TreId "
        //    + " WHERE     (TblNamtrehoc.LophocId = @LophocId) AND (TblTre.Tinhtrang = 0) AND (TblTre.Hovaten LIKE '%' + @Hotendem + '%') AND  "
        //    + "                       (TblTre.Tenthuonggoi LIKE '%' + @Tenthuonggoi + '%') AND (TblDm_Uutien.Tenuutien LIKE '%' + @UutienId + '%') AND  "
        //    + "                       (TblTre.Noiohiennay LIKE '%' + @Noiohiennay + '%') AND (TblTre.Gioitinh LIKE '%' + @Gioitinh + '%') AND (TblNamtrehoc.NamhocId = ?) "
        //    + " ORDER BY TblTre.Ten "
        //    ;
        public static string SP_TRE_SEARCH = ""
 + " SELECT Id, Hotendem, Ten, Hovaten, Tenthuonggoi, Ngaysinh, Gioitinh, Noiohiennay, UutienId, Sodt, "
 + "        Tinhtrang, Hotenme, Nghengheme, Hotenbo, Nghenghiepbo, NamtrehocId, Ghichu "
 + " FROM  vwTre "
 + " WHERE Tinhtrang = 0 AND Hovaten LIKE '*?*' "
 + "   AND Tenthuonggoi LIKE '*?*' AND Tenuutien LIKE '*?*' "
 + "   AND Noiohiennay LIKE '*?*' AND Gioitinh LIKE '*?*' "
            //+ "   AND NamhocId = ? "//
 + " AND LophocId = ?"
 + " ORDER BY Ten ";

        public static string SP_TRE_SEARCHALL = " "
 + " SELECT  TblTre.Id, TblTre.Hovaten, TblTre.Hotendem, TblTre.Ten, TblTre.Tenthuonggoi, "
 + " 		TblTre.Ngaysinh, TblTre.Gioitinh, TblTre.Sodt, TblTre.Noiohiennay, TblTre.UutienId, "
 + " 		TblTre.Tinhtrang, TblTre.Hotenme, TblTre.Nghengheme, TblTre.Hotenbo, TblTre.Nghenghiepbo,  "
 + " 		TblNamtrehoc.Id AS NamtrehocId, TblTre.Ghichu "
 + " FROM  (TblTre INNER JOIN TblDm_Uutien ON TblDm_Uutien.Id = TblTre.UutienId) INNER JOIN TblNamtrehoc ON TblTre.Id = TblNamtrehoc.TreId "
 + " WHERE (TblTre.Tinhtrang = 0) AND (TblTre.Hovaten LIKE '%?%') AND (TblTre.Tenthuonggoi LIKE '%?%') AND  "
 + "       (TblDm_Uutien.Tenuutien LIKE '%?%') AND (TblTre.Noiohiennay LIKE '%?%') AND  "
 + "       (TblTre.Gioitinh LIKE '%?%') AND (TblNamtrehoc.NamhocId = ?) "
 + " ORDER BY TblTre.Ten ";

        public static string SPROC_TBLTRE_GETBYHOTENDEMANDTEN = "SELECT      TblTre.Id, TblTre.Hotendem, TblTre.Ten, TblTre.Hovaten, TblTre.Tenthuonggoi, TblTre.Ngaysinh, "
 + "                       TblTre.Gioitinh, TblTre.Noiohiennay, TblTre.UutienId, TblTre.Sodt, TblTre.Tinhtrang, TblTre.Hotenbo,  "
 + "                       TblTre.Nghenghiepbo, TblTre.Hotenme, TblTre.Nghengheme, TblTre.Ghichu "
 + " FROM         TblTre INNER JOIN "
 + "                       TblDm_Uutien ON TblDm_Uutien.Id = TblTre.UutienId "
 + " WHERE     (TblTre.Tinhtrang = 0) AND (TblTre.Hotendem LIKE '%' + @Varname + '%') OR "
 + "                       (TblTre.Tinhtrang = 0) AND (TblTre.Ten LIKE '%' + @Varname + '%') "
 + " ORDER BY TblTre.Ten ";
        public static string SPROC_TBLTRE_GETBYID = "SELECT TblTre.Id, TblTre.Hotendem, TblTre.Ten, TblTre.Hovaten, TblTre.Tenthuonggoi, TblTre.Ngaysinh, TblTre.Gioitinh, TblTre.Noiohiennay, TblTre.UutienId, TblTre.Sodt, TblTre.Tinhtrang, TblTre.Hotenbo, TblTre.Nghenghiepbo, TblTre.Hotenme, TblTre.Nghengheme, TblTre.Ghichu, TblDm_Dantoc.Id as DantocId" +
" FROM TblDm_Dantoc INNER JOIN (TblDm_Uutien INNER JOIN TblTre ON TblDm_Uutien.Id = TblTre.UutienId) ON TblDm_Dantoc.Id = TblTre.DantocId " +
" WHERE (((TblTre.Id)=[@Id]) AND ((TblTre.Tinhtrang)=0))";
        public static string SPROC_TBLTRE_GETBYLOPHOCID = "SELECT      TblTre.Id, TblTre.Hotendem, TblTre.Ten, TblTre.Hovaten, TblTre.Tenthuonggoi, TblTre.Ngaysinh, "
 + "                       TblTre.Gioitinh, TblTre.Noiohiennay, TblTre.UutienId, TblTre.Sodt, TblTre.Tinhtrang, TblTre.Nghengheme,  "
 + "                       TblTre.Hotenme, TblTre.Nghenghiepbo, TblTre.Hotenbo, TblNamtrehoc.Id AS NamtrehocId, TblTre.Ghichu "
 + " FROM         TblTre INNER JOIN "
 + "                       TblDm_Uutien ON TblDm_Uutien.Id = TblTre.UutienId INNER JOIN "
 + "                       TblNamtrehoc ON TblTre.Id = TblNamtrehoc.TreId "
 + " WHERE     (TblNamtrehoc.LophocId = @LophocId) "
 + " ORDER BY TblTre.Ten ";
        public static string SPROC_TBLTRE_GETTOPNBYID = "SELECT max(Id) as Id FROM TblTre ";
        public static string SPROC_TBLTRE_UPDATE = "UPDATE TblTre"
 + " SET Hotendem = '@Hotendem', Ten = '@Tenchinh', "
 + "  Hovaten = '@Hovaten', "
 + " Tenthuonggoi = '@Tenthuongoi', "
 + " Ngaysinh = '@Ngaysinh', Noiohiennay ='@Noiohiennay', "
 + "  Gioitinh = '@Gioitinh', Sodt = '@Sodt', "
 + "  UutienId = @UutienId, "
 + "  Hotenbo = '@Hotenbo', "
 + "  Nghenghiepbo = '@Nghenghiepbo',  "
 + " Hotenme = '@Hotenme', Nghengheme = '@Nghenghiepme', Ghichu = '@Ghichu', Tinhtrang ='0', DantocId =@DantocId, Vungmien ='@Vungmien', Ngaynhaphoc =#@Ngaynhaphoc# ,Emailph ='@Emailph', Thoiquentre ='@Thoiquentre'"
 + " WHERE Id = @Id";
        public static string SPROC_TBLTRE_UPDATETINHTRANG = "UPDATE TblTre"
 + " SET	 Tinhtrang = ? "
 + " WHERE Id =?";
        public static string SPROC_TBLTREKIEMTRANHANTHUC_ADD = "INSERT INTO TblTrekiemtranhanthuc(NamtrehocId, NhanthucId, ThanghocId, Ngaykiemtra, Datchuan ) VALUES(@NamtrehocId, @NhanthucId, @ThanghocId, '@Ngaykiemtra', '@Datchuan') ";
        public static string SPROC_TBLTREKIEMTRANHANTHUC_GET = "if(@LophocId =-1)"
 + " SELECT     TblTrekiemtranhanthuc.Id, TblTrekiemtranhanthuc.NamtrehocId, Vw_Tre_namtrehoc.NamhocId, Vw_Tre_namtrehoc.LophocId,  "
 + "                       TblTrekiemtranhanthuc.ThanghocId, Vw_Tre_namtrehoc.Hovaten, Vw_Tre_namtrehoc.Tenthuonggoi,  "
 + "                        TblTrekiemtranhanthuc.Datchuan ,TblTrekiemtranhanthuc.Ngaykiemtra, TblTrekiemtranhanthuc.NhanthucId "
 + " FROM         Vw_Tre_namtrehoc INNER JOIN "
 + "                       TblTrekiemtranhanthuc ON Vw_Tre_namtrehoc.NamtrehocId = TblTrekiemtranhanthuc.NamtrehocId "
 + " where ( "
 + " Vw_Tre_namtrehoc.NamhocId =? and   "
 + "                       TblTrekiemtranhanthuc.ThanghocId =? and  TblTrekiemtranhanthuc.NhanthucId =@NhanthucId "
 + " ) "
 + " else "
 + " SELECT     TblTrekiemtranhanthuc.Id, TblTrekiemtranhanthuc.NamtrehocId, Vw_Tre_namtrehoc.NamhocId, Vw_Tre_namtrehoc.LophocId,  "
 + "                       TblTrekiemtranhanthuc.ThanghocId, Vw_Tre_namtrehoc.Hovaten, Vw_Tre_namtrehoc.Tenthuonggoi,  "
 + "                        TblTrekiemtranhanthuc.Datchuan ,TblTrekiemtranhanthuc.Ngaykiemtra, TblTrekiemtranhanthuc.NhanthucId "
 + " FROM         Vw_Tre_namtrehoc INNER JOIN "
 + "                       TblTrekiemtranhanthuc ON Vw_Tre_namtrehoc.NamtrehocId = TblTrekiemtranhanthuc.NamtrehocId "
 + " where ( "
 + " Vw_Tre_namtrehoc.NamhocId =? and Vw_Tre_namtrehoc.LophocId = ? and   "
 + "                       TblTrekiemtranhanthuc.ThanghocId =? and  TblTrekiemtranhanthuc.NhanthucId =@NhanthucId "
 + " ) ";
        //"if(@LophocId =-1)"
        public static string SPROC_TBLTREKIEMTRANHANTHUC_GET1 =
           " SELECT     TblTrekiemtranhanthuc.Id, TblTrekiemtranhanthuc.NamtrehocId, Vw_Tre_namtrehoc.NamhocId, Vw_Tre_namtrehoc.LophocId,  "
           + "                       TblTrekiemtranhanthuc.ThanghocId, Vw_Tre_namtrehoc.Hovaten, Vw_Tre_namtrehoc.Tenthuonggoi,  "
           + "                        TblTrekiemtranhanthuc.Datchuan ,TblTrekiemtranhanthuc.Ngaykiemtra, TblTrekiemtranhanthuc.NhanthucId "
           + " FROM         Vw_Tre_namtrehoc INNER JOIN "
           + "                       TblTrekiemtranhanthuc ON Vw_Tre_namtrehoc.NamtrehocId = TblTrekiemtranhanthuc.NamtrehocId "
           + " where ( "
           + " Vw_Tre_namtrehoc.NamhocId =@NamhocId and   "
           + "                       TblTrekiemtranhanthuc.ThanghocId =@ThanghocId and  TblTrekiemtranhanthuc.NhanthucId =@NhanthucId "
           + " ) ";
        // else
        public static string SPROC_TBLTREKIEMTRANHANTHUC_GET2 =
            " SELECT     TblTrekiemtranhanthuc.Id, TblTrekiemtranhanthuc.NamtrehocId, Vw_Tre_namtrehoc.NamhocId, Vw_Tre_namtrehoc.LophocId,  "
           + "                       TblTrekiemtranhanthuc.ThanghocId, Vw_Tre_namtrehoc.Hovaten, Vw_Tre_namtrehoc.Tenthuonggoi,  "
           + "                        TblTrekiemtranhanthuc.Datchuan ,TblTrekiemtranhanthuc.Ngaykiemtra, TblTrekiemtranhanthuc.NhanthucId "
           + " FROM         Vw_Tre_namtrehoc INNER JOIN "
           + "                       TblTrekiemtranhanthuc ON Vw_Tre_namtrehoc.NamtrehocId = TblTrekiemtranhanthuc.NamtrehocId "
           + " where ( "
           + " Vw_Tre_namtrehoc.NamhocId =@NamhocId and Vw_Tre_namtrehoc.LophocId = @LophocId and   "
           + "                       TblTrekiemtranhanthuc.ThanghocId =@ThanghocId and  TblTrekiemtranhanthuc.NhanthucId =@NhanthucId "
           + " ) ";
        //**********************************************************
        public static string SPROC_TBLPHIEUBENGOAN_GET1 =
            " SELECT     TblPhieuBeNgoan.Id, TblPhieuBeNgoan.IdNam, Vw_Tre_namtrehoc.NamhocId, Vw_Tre_namtrehoc.LophocId,  "
           + "                       TblPhieuBeNgoan.IdThang, Vw_Tre_namtrehoc.Hovaten, Vw_Tre_namtrehoc.Tenthuonggoi,  "
           + "                        TblPhieuBeNgoan.Tuan1, TblPhieuBeNgoan.Tuan2, TblPhieuBeNgoan.Tuan3, TblPhieuBeNgoan.Tuan4 "
           + " FROM         Vw_Tre_namtrehoc INNER JOIN "
           + "                       TblPhieuBeNgoan ON Vw_Tre_namtrehoc.NamtrehocId = TblPhieuBeNgoan.IdNam "
           + " where ( "
           + " Vw_Tre_namtrehoc.NamhocId =@NamhocId and Vw_Tre_namtrehoc.LophocId = @LophocId and   "
           + "                       TblPhieuBeNgoan.IdThang = @ThanghocId"
           + " ) ";
        //**********************************************************
        public static string SPROC_TBLTREKIEMTRANHANTHUC_UPDATE = "UPDATE TblTrekiemtranhanthuc"
 + " SET Ngaykiemtra = '@Ngaykiemtra', "
 + " 	Datchuan = '@Datchuan' "
 + " WHERE Id =@Id";
        public static string SPROC_TBLTREKIEMTRASUCKHOE = "if(@LophocId =-1)"
 + " 	SELECT     Tinhtrang, NamhocId, LophocId, TreId, NamtrehocId, Tenthuonggoi, Hovaten "
 + " FROM         Vw_Tre_namtrehoc "
 + " where(NamhocId =? ) "
 + " else "
 + " 	SELECT     Tinhtrang, NamhocId, LophocId, TreId, NamtrehocId, Tenthuonggoi, Hovaten "
 + " FROM         Vw_Tre_namtrehoc "
 + " where(NamhocId = ? and LophocId = ?) ";
        public static string SPROC_TBLTREKIEMTRASUCKHOE1 =
           " 	SELECT     Tinhtrang, NamhocId, LophocId, TreId, NamtrehocId, Tenthuonggoi, Hovaten "
           + " FROM         Vw_Tre_namtrehoc "
           + " where(NamhocId =? ) ";
        public static string SPROC_TBLTREKIEMTRASUCKHOE2 =
           " 	SELECT     Tinhtrang, NamhocId, LophocId, TreId, NamtrehocId, Tenthuonggoi, Hovaten "
           + " FROM         Vw_Tre_namtrehoc "
           + " where(NamhocId = ? and LophocId = ?) ";

        public static string SPROC_TBLPHIEUBENGOAN_TT =
           " 	SELECT     TreId, Hovaten, Gioitinh, Ngaysinh, Tendantoc "
           + " FROM         Vw_Tre_namtrehoc "
           + " where(NamhocId = ? and LophocId = ?) ";

        public static string SPROC_TBLTREKIEMTRASUCKHOE_ADD = "	INSERT INTO TblTrekiemtrasuckhoe"
 + " 	( 	NamtrehocId, "
 + " 		Ngaykiemtra, "
 + " 		ThanghocId, "
 + " 		Cannang, "
 + " 		Chieucao, "
 + " 		Danhgia, Saurang, Benhkhac ,KqCannang, KqChieucao) "
 + " 	VALUES ( @NamtrehocId, @Ngaykiemtra,@ThanghocId, @Cannang, @Chieucao, '@Danhgia','@Saurang','@Benhkhac','@KqCannang','@KqChieucao' ) ";
        public static string SPROC_TBLTREKIEMTRASUCKHOE_GET = "if(@LophocId =-1)"
 + " 	SELECT  TblTrekiemtrasuckhoe.Id,  "
 + " 			Vw_Tre_namtrehoc.NamtrehocId,  "
 + " 			Vw_Tre_namtrehoc.LophocId,  "
 + " 			Vw_Tre_namtrehoc.NamhocId,  "
 + " 			Vw_Tre_namtrehoc.Hovaten,  "
 + " 			Vw_Tre_namtrehoc.Tenthuonggoi, TblTrekiemtrasuckhoe.ThanghocId,  "
 + "             TblTrekiemtrasuckhoe.Ngaykiemtra, 			 "
 + " 			TblTrekiemtrasuckhoe.Chieucao, TblTrekiemtrasuckhoe.Cannang, "
 + " 			TblTrekiemtrasuckhoe.Danhgia "
 + " FROM         Vw_Tre_namtrehoc INNER JOIN "
 + "                       TblTrekiemtrasuckhoe ON Vw_Tre_namtrehoc.NamtrehocId = TblTrekiemtrasuckhoe.NamtrehocId "
 + " where  (Vw_Tre_namtrehoc.NamhocId =?) and (TblTrekiemtrasuckhoe.ThanghocId =?) "
 + " else "
 + " 	SELECT    TblTrekiemtrasuckhoe.Id,  "
 + " 			Vw_Tre_namtrehoc.NamtrehocId,  "
 + " 			Vw_Tre_namtrehoc.LophocId,  "
 + " 			Vw_Tre_namtrehoc.NamhocId,  "
 + " 			Vw_Tre_namtrehoc.Hovaten,  "
 + " 			Vw_Tre_namtrehoc.Tenthuonggoi, TblTrekiemtrasuckhoe.ThanghocId,  "
 + "             TblTrekiemtrasuckhoe.Ngaykiemtra, 			 "
 + " 			TblTrekiemtrasuckhoe.Chieucao, TblTrekiemtrasuckhoe.Cannang, "
 + " 			TblTrekiemtrasuckhoe.Danhgia "
 + " FROM         Vw_Tre_namtrehoc INNER JOIN "
 + "                       TblTrekiemtrasuckhoe ON Vw_Tre_namtrehoc.NamtrehocId = TblTrekiemtrasuckhoe.NamtrehocId "
 + " where (Vw_Tre_namtrehoc.LophocId = ?) and (Vw_Tre_namtrehoc.NamhocId = ?) and (TblTrekiemtrasuckhoe.ThanghocId = ?) ";
        public static string SPROC_TBLTREKIEMTRASUCKHOE_UPDATE = "UPDATE TblTrekiemtrasuckhoe"
 + " SET NamtrehocId = @NamtrehocId, "
 + " 	Ngaykiemtra = @Ngaykiemtra, "
 + " 	Cannang = @Cannang, "
 + " 	ThanghocId = @ThanghocId, "
 + " 	Chieucao = @Chieucao, "
 + " 	Danhgia = '@Danhgia', Saurang = '@Saurang', Benhkhac ='@Benhkhac' , KqCannang ='@KqCannang', KqChieucao ='@KqChieucao'"
 + " WHERE Id =@Id";
        public static string SPROC_TBLTREMACBENH_ADD = "INSERT INTO TblTremacbenh"
 + " 	( 	NamtrehocId, "
 + " 		BenhlyId, "
 + " 		Noidieutri, "
 + " 		Ngaynhap, "
 + " 		Ngayxuat, "
 + " 		Ghichu "
 + " 	) VALUES ( ?, ?, ?, ?, ?, ?) ";
        public static string SPROC_TBLTREMACBENH_DELETE = "DELETE FROM TblTremacbenh WHERE Id =?";
        public static string SPROC_TBLTREMACBENH_GETBYID = "SELECT"
 + " 	TblTremacbenh.Id, "
 + " TblTremacbenh.NamtrehocId, "
 + " 	TblTremacbenh.BenhlyId, "
 + " 	TblTremacbenh.Noidieutri, "
 + " 	TblTremacbenh.Ngaynhap, "
 + " 	TblTremacbenh.Ngayxuat, "
 + " 	TblTremacbenh.Ghichu "
 + " FROM TblTremacbenh inner join TblNamtrehoc on TblTremacbenh.NamtrehocId =TblNamtrehoc.Id "
 + " WHERE TblTremacbenh.NamtrehocId = ? and TblNamtrehoc.NamhocId =? ";
        public static string SPROC_TBLTREMACBENH_UPDATE = "UPDATE TblTremacbenh"
 + " SET NamtrehocId = '@NamtrehocId', "
 + " 	BenhlyId = @BenhlyId, "
 + " 	Noidieutri = '@Noidieutri', "
 + " 	Ngaynhap = '@Ngaynhap', "
 + " 	Ngayxuat = '@Ngayxuat', "
 + " 	Ghichu = '@Ghichu' "
 + " WHERE Id = @Id";
        public static string SPROC_TBLTRENGHIHOC_ADD = "INSERT INTO TblTrenghihoc"
 + " 	( 	NamtrehocId, "
 + " 		Tungay, "
 + " 		Denngay, "
 + " 		Nguyennhan) VALUES (?, ?, ?, ?) ";
        public static string SPROC_TBLTRENGHIHOC_DELETE = "DELETE FROM TblTrenghihoc WHERE Id =?";
        public static string SPROC_TBLTRENGHIHOC_GETBYID = "SELECT"
 + " 	TblTrenghihoc.Id, "
 + " 	TblTrenghihoc.NamtrehocId, "
 + " 	TblTrenghihoc.Tungay, "
 + " 	TblTrenghihoc.Denngay, "
 + " 	TblTrenghihoc.Nguyennhan "
 + " FROM TblTrenghihoc inner join TblNamtrehoc on TblNamtrehoc.Id = TblTrenghihoc.NamtrehocId "
 + " WHERE TblTrenghihoc.NamtrehocId = ? and TblNamtrehoc.NamhocId = ? ";
        public static string SPROC_TBLTRENGHIHOC_GETCOUNT = "SELECT COUNT(*) FROM TblTrenghihoc ";
        public static string SPROC_TBLTRENGHIHOC_UPDATE = "UPDATE TblTrenghihoc  SET NamtrehocId = @NamtrehocId, Tungay ='@Tungay', Denngay = '@Denngay',Nguyennhan ='@Nguyennhan' WHERE Id =@Id";
        public static string SPROC_TBLTRENOPTUNGUYEN = "if(@LophocId =-1)"
 + " SELECT     Hovaten, Tenthuonggoi, NamtrehocId, LophocId "
 + " FROM         Vw_Tre_namtrehoc "
 + " WHERE     (NamhocId = ?)  "
 + " else "
 + " SELECT     Hovaten, Tenthuonggoi, NamtrehocId, LophocId "
 + " FROM         Vw_Tre_namtrehoc "
 + " WHERE     (NamhocId = ?) AND (LophocId = @LophocId) ";
        public static string SPROC_TBLTRENOPTUNGUYEN_ADD = "INSERT INTO TblTrenoptunguyen"
 + " 	( 	NamtrehocId, "
 + " 		ThukhongbatbuocId, "
 + " 		Ngaydong, "
 + " 		Tiendong ) VALUES ( ?, ?, ?, ?) ";
        public static string SPROC_TBLTRENOPTUNGUYEN_GET = "if(@LophocId =-1)"
 + " SELECT     Vw_Tre_namtrehoc.NamtrehocId, TblTrenoptunguyen.Id, Vw_Tre_namtrehoc.LophocId, Vw_Tre_namtrehoc.Hovaten,  "
 + "                       Vw_Tre_namtrehoc.Tenthuonggoi, TblTrenoptunguyen.ThukhongbatbuocId, TblTrenoptunguyen.Ngaydong,  "
 + "                       TblTrenoptunguyen.Tiendong "
 + " FROM         Vw_Tre_namtrehoc INNER JOIN "
 + "                       TblTrenoptunguyen ON Vw_Tre_namtrehoc.NamtrehocId = TblTrenoptunguyen.NamtrehocId "
 + " WHERE     (Vw_Tre_namtrehoc.NamhocId = ?)  AND  "
 + "                       (TblTrenoptunguyen.ThukhongbatbuocId = @ThukhongbatbuocId) "
 + " else "
 + " SELECT     Vw_Tre_namtrehoc.NamtrehocId, TblTrenoptunguyen.Id, Vw_Tre_namtrehoc.LophocId, Vw_Tre_namtrehoc.Hovaten,  "
 + "                       Vw_Tre_namtrehoc.Tenthuonggoi, TblTrenoptunguyen.ThukhongbatbuocId, TblTrenoptunguyen.Ngaydong,  "
 + "                       TblTrenoptunguyen.Tiendong "
 + " FROM         Vw_Tre_namtrehoc INNER JOIN "
 + "                       TblTrenoptunguyen ON Vw_Tre_namtrehoc.NamtrehocId = TblTrenoptunguyen.NamtrehocId "
 + " WHERE     (Vw_Tre_namtrehoc.NamhocId = ?) AND (Vw_Tre_namtrehoc.LophocId = @LophocId) AND  "
 + "                       (TblTrenoptunguyen.ThukhongbatbuocId = @ThukhongbatbuocId) ";
        public static string SPROC_TBLTRENOPTUNGUYEN_UPDATE = "UPDATE TblTrenoptunguyen"
 + " SET NamtrehocId = ?, "
 + " 	ThukhongbatbuocId = ?, "

 + " 	Tiendong = ? "
 + " WHERE Id =?";
        public static string SPROC_TBLTREPHAITHUNAM = "";
        public static string SPROC_TBLTREPHAITHUNAM_ADD = "	INSERT INTO TblTrephaithunam"
 + " 	( 	NamtrehocId, "
 + " 		ThudaunamId, "
 + " 		Mucthu, "
 + " 		Duocgiam, "
 + " 		Phainop, "
 + " 		Danop, "
 + " 		Conlai, "
 + " 		Nopthem "
 + " 	) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?) ";
        public static string SPROC_TBLTREPHAITHUNAM_BYNAMHOCID_THUDAUNAMID_TENLOP = "if(@Varvalue =1) -- Nhombot"
 + " SELECT     TblDsLopphainop.NamtrehocId, TblTrephaithunam.Id, TblDsLopphainop.LophocId, TblDsLopphainop.Hovaten, TblDsLopphainop.Tenthuonggoi,  "
 + "                       TblDsLopphainop.ThudaunamId, TblDsLopphainop.Mucthu_Nhombot AS Mucthu, TblDsLopphainop.Nhombot_Duocgiam AS Duocgiam,  "
 + "                       TblDsLopphainop.Nhombot_Phainop AS Phainop, ISNULL(TblTrephaithunam.Danop, 0) AS Danop, ISNULL(TblTrephaithunam.Conlai, 0)  "
 + "                       AS Conlai, ISNULL(TblTrephaithunam.Nopthem, 0) AS Nopthem "
 + " FROM         (SELECT     NamtrehocId, LophocId, Hovaten, Tenthuonggoi, UutienId, ThudaunamId, Dinhmucgiam * Dm_Nhomchao / 100 AS Nhomchao_Duocgiam,  "
 + "                                               Dinhmucgiam * Dm_Nhombot / 100 AS Nhombot_Duocgiam, Dinhmucgiam * Dm_Nhatre / 100 AS Nhatre_Duocgiam,  "
 + "                                               Dinhmucgiam * Dm_Maugiao / 100 AS Maugiao_Duocgiam, Dm_Nhomchao AS Mucthu_Nhomchao, Dm_Nhombot AS Mucthu_Nhombot,  "
 + "                                               Dm_Maugiao AS Mucthu_Maugiao, Dm_Nhatre AS Mucthu_Nhatre,  "
 + "                                               Dm_Nhomchao - Dinhmucgiam * Dm_Nhomchao / 100 AS Nhomchao_Phainop,  "
 + "                                               Dm_Nhombot - Dinhmucgiam * Dm_Nhombot / 100 AS Nhombot_Phainop,  "
 + "                                               Dm_Maugiao - Dinhmucgiam * Dm_Maugiao / 100 AS Maugiao_Phainop,  "
 + "                                               Dm_Nhatre - Dinhmucgiam * Dm_Nhatre / 100 AS Nhatre_Phainop "
 + "                        FROM          (SELECT     TblDs.NamtrehocId, TblDs.LophocId, TblDs.Hovaten, TblDs.Tenthuonggoi, TblDs.UutienId,  "
 + "                                                                       TblMucgiamuutiennam.ThudaunamId, ISNULL(TblMucgiamuutiennam.Dinhmucgiam, 0) AS Dinhmucgiam,  "
 + "                                                                       ISNULL(TblDm_Thudaunam.Dm_Nhomchao, 0) AS Dm_Nhomchao, ISNULL(TblDm_Thudaunam.Dm_Nhombot, 0)  "
 + "                                                                       AS Dm_Nhombot, ISNULL(TblDm_Thudaunam.Dm_Maugiao, 0) AS Dm_Maugiao,  "
 + "                                                                       ISNULL(TblDm_Thudaunam.Dm_Nhatre, 0) AS Dm_Nhatre "
 + "                                                FROM          (SELECT     TblNamtrehoc.Id AS NamtrehocId, TblNamtrehoc.LophocId, TblTre.Hovaten, TblTre.Tenthuonggoi,  "
 + "                                                                                               TblTre.UutienId, TblDm_Khoilop.Tenkhoilop "
 + "                                                                        FROM          TblTre INNER JOIN "
 + "                                                                                               TblNamtrehoc ON TblTre.Id = TblNamtrehoc.TreId INNER JOIN "
 + "                                                                                               TblLop ON TblNamtrehoc.LophocId = TblLop.Id INNER JOIN "
 + "                                                                                               TblDm_Phanloailop ON TblLop.PhanloailopId = TblDm_Phanloailop.Id INNER JOIN "
 + "                                                                                               TblDm_Khoilop ON TblDm_Phanloailop.KhoilopID = TblDm_Khoilop.Id "
 + "                                                                        WHERE      (TblLop.Tenlop LIKE N'%' + @Tenlop + N'%') AND (TblNamtrehoc.NamhocId = ?))  "
 + "                                                                       AS TblDs INNER JOIN "
 + "                                                                       TblMucgiamuutiennam ON TblDs.UutienId = TblMucgiamuutiennam.UutienId INNER JOIN "
 + "                                                                       TblDm_Thudaunam ON TblMucgiamuutiennam.ThudaunamId = TblDm_Thudaunam.Id "
 + "                                                WHERE      (TblMucgiamuutiennam.ThudaunamId = @ThudaunamId)) AS TblDsLop_Dinhmucgian_phainop)  "
 + "                       AS TblDsLopphainop LEFT OUTER JOIN "
 + "                       TblTrephaithunam ON TblDsLopphainop.NamtrehocId = TblTrephaithunam.NamtrehocId "
 + " if(@Varvalue =2) -- Nhomnhomchao "
 + " SELECT     TblDsLopphainop.NamtrehocId, TblTrephaithunam.Id, TblDsLopphainop.LophocId, TblDsLopphainop.Hovaten, TblDsLopphainop.Tenthuonggoi,  "
 + "                       TblDsLopphainop.ThudaunamId, TblDsLopphainop.Mucthu_Nhomchao AS Mucthu, TblDsLopphainop.Nhomchao_Duocgiam AS Duocgiam,  "
 + "                       TblDsLopphainop.Nhomchao_Phainop AS Phainop, ISNULL(TblTrephaithunam.Danop, 0) AS Danop, ISNULL(TblTrephaithunam.Conlai, 0)  "
 + "                       AS Conlai, ISNULL(TblTrephaithunam.Nopthem, 0) AS Nopthem "
 + " FROM         (SELECT     NamtrehocId, LophocId, Hovaten, Tenthuonggoi, UutienId, ThudaunamId, Dinhmucgiam * Dm_Nhomchao / 100 AS Nhomchao_Duocgiam,  "
 + "                                               Dinhmucgiam * Dm_Nhombot / 100 AS Nhombot_Duocgiam, Dinhmucgiam * Dm_Nhatre / 100 AS Nhatre_Duocgiam,  "
 + "                                               Dinhmucgiam * Dm_Maugiao / 100 AS Maugiao_Duocgiam, Dm_Nhomchao AS Mucthu_Nhomchao, Dm_Nhombot AS Mucthu_Nhombot,  "
 + "                                               Dm_Maugiao AS Mucthu_Maugiao, Dm_Nhatre AS Mucthu_Nhatre,  "
 + "                                               Dm_Nhomchao - Dinhmucgiam * Dm_Nhomchao / 100 AS Nhomchao_Phainop,  "
 + "                                               Dm_Nhombot - Dinhmucgiam * Dm_Nhombot / 100 AS Nhombot_Phainop,  "
 + "                                               Dm_Maugiao - Dinhmucgiam * Dm_Maugiao / 100 AS Maugiao_Phainop,  "
 + "                                               Dm_Nhatre - Dinhmucgiam * Dm_Nhatre / 100 AS Nhatre_Phainop "
 + "                        FROM          (SELECT     TblDs.NamtrehocId, TblDs.LophocId, TblDs.Hovaten, TblDs.Tenthuonggoi, TblDs.UutienId,  "
 + "                                                                       TblMucgiamuutiennam.ThudaunamId, ISNULL(TblMucgiamuutiennam.Dinhmucgiam, 0) AS Dinhmucgiam,  "
 + "                                                                       ISNULL(TblDm_Thudaunam.Dm_Nhomchao, 0) AS Dm_Nhomchao, ISNULL(TblDm_Thudaunam.Dm_Nhombot, 0)  "
 + "                                                                       AS Dm_Nhombot, ISNULL(TblDm_Thudaunam.Dm_Maugiao, 0) AS Dm_Maugiao,  "
 + "                                                                       ISNULL(TblDm_Thudaunam.Dm_Nhatre, 0) AS Dm_Nhatre "
 + "                                                FROM          (SELECT     TblNamtrehoc.Id AS NamtrehocId, TblNamtrehoc.LophocId, TblTre.Hovaten, TblTre.Tenthuonggoi,  "
 + "                                                                                               TblTre.UutienId, TblDm_Khoilop.Tenkhoilop "
 + "                                                                        FROM          TblTre INNER JOIN "
 + "                                                                                               TblNamtrehoc ON TblTre.Id = TblNamtrehoc.TreId INNER JOIN "
 + "                                                                                               TblLop ON TblNamtrehoc.LophocId = TblLop.Id INNER JOIN "
 + "                                                                                               TblDm_Phanloailop ON TblLop.PhanloailopId = TblDm_Phanloailop.Id INNER JOIN "
 + "                                                                                               TblDm_Khoilop ON TblDm_Phanloailop.KhoilopID = TblDm_Khoilop.Id "
 + "                                                                        WHERE      (TblLop.Tenlop LIKE N'%' + @Tenlop + N'%') AND (TblNamtrehoc.NamhocId = ?))  "
 + "                                                                       AS TblDs INNER JOIN "
 + "                                                                       TblMucgiamuutiennam ON TblDs.UutienId = TblMucgiamuutiennam.UutienId INNER JOIN "
 + "                                                                       TblDm_Thudaunam ON TblMucgiamuutiennam.ThudaunamId = TblDm_Thudaunam.Id "
 + "                                                WHERE      (TblMucgiamuutiennam.ThudaunamId = @ThudaunamId)) AS TblDsLop_Dinhmucgian_phainop)  "
 + "                       AS TblDsLopphainop LEFT OUTER JOIN "
 + "                       TblTrephaithunam ON TblDsLopphainop.NamtrehocId = TblTrephaithunam.NamtrehocId "
 + " if(@Varvalue =3) -- Nhatre "
 + " SELECT     TblDsLopphainop.NamtrehocId, TblTrephaithunam.Id, TblDsLopphainop.LophocId, TblDsLopphainop.Hovaten, TblDsLopphainop.Tenthuonggoi,  "
 + "                       TblDsLopphainop.ThudaunamId, TblDsLopphainop.Mucthu_Nhatre AS Mucthu, TblDsLopphainop.Nhatre_Duocgiam AS Duocgiam,  "
 + "                       TblDsLopphainop.Nhatre_Phainop AS Phainop, ISNULL(TblTrephaithunam.Danop, 0) AS Danop, ISNULL(TblTrephaithunam.Conlai, 0) AS Conlai,  "
 + "                       ISNULL(TblTrephaithunam.Nopthem, 0) AS Nopthem "
 + " FROM         (SELECT     NamtrehocId, LophocId, Hovaten, Tenthuonggoi, UutienId, ThudaunamId, Dinhmucgiam * Dm_Nhomchao / 100 AS Nhomchao_Duocgiam,  "
 + "                                               Dinhmucgiam * Dm_Nhombot / 100 AS Nhombot_Duocgiam, Dinhmucgiam * Dm_Nhatre / 100 AS Nhatre_Duocgiam,  "
 + "                                               Dinhmucgiam * Dm_Maugiao / 100 AS Maugiao_Duocgiam, Dm_Nhomchao AS Mucthu_Nhomchao, Dm_Nhombot AS Mucthu_Nhombot,  "
 + "                                               Dm_Maugiao AS Mucthu_Maugiao, Dm_Nhatre AS Mucthu_Nhatre,  "
 + "                                               Dm_Nhomchao - Dinhmucgiam * Dm_Nhomchao / 100 AS Nhomchao_Phainop,  "
 + "                                               Dm_Nhombot - Dinhmucgiam * Dm_Nhombot / 100 AS Nhombot_Phainop,  "
 + "                                               Dm_Maugiao - Dinhmucgiam * Dm_Maugiao / 100 AS Maugiao_Phainop,  "
 + "                                               Dm_Nhatre - Dinhmucgiam * Dm_Nhatre / 100 AS Nhatre_Phainop "
 + "                        FROM          (SELECT     TblDs.NamtrehocId, TblDs.LophocId, TblDs.Hovaten, TblDs.Tenthuonggoi, TblDs.UutienId,  "
 + "                                                                       TblMucgiamuutiennam.ThudaunamId, ISNULL(TblMucgiamuutiennam.Dinhmucgiam, 0) AS Dinhmucgiam,  "
 + "                                                                       ISNULL(TblDm_Thudaunam.Dm_Nhomchao, 0) AS Dm_Nhomchao, ISNULL(TblDm_Thudaunam.Dm_Nhombot, 0)  "
 + "                                                                       AS Dm_Nhombot, ISNULL(TblDm_Thudaunam.Dm_Maugiao, 0) AS Dm_Maugiao,  "
 + "                                                                       ISNULL(TblDm_Thudaunam.Dm_Nhatre, 0) AS Dm_Nhatre "
 + "                                                FROM          (SELECT     TblNamtrehoc.Id AS NamtrehocId, TblNamtrehoc.LophocId, TblTre.Hovaten, TblTre.Tenthuonggoi,  "
 + "                                                                                               TblTre.UutienId, TblDm_Khoilop.Tenkhoilop "
 + "                                                                        FROM          TblTre INNER JOIN "
 + "                                                                                               TblNamtrehoc ON TblTre.Id = TblNamtrehoc.TreId INNER JOIN "
 + "                                                                                               TblLop ON TblNamtrehoc.LophocId = TblLop.Id INNER JOIN "
 + "                                                                                               TblDm_Phanloailop ON TblLop.PhanloailopId = TblDm_Phanloailop.Id INNER JOIN "
 + "                                                                                               TblDm_Khoilop ON TblDm_Phanloailop.KhoilopID = TblDm_Khoilop.Id "
 + "                                                                        WHERE      (TblLop.Tenlop LIKE N'%' + @Tenlop + N'%') AND (TblNamtrehoc.NamhocId = ?))  "
 + "                                                                       AS TblDs INNER JOIN "
 + "                                                                       TblMucgiamuutiennam ON TblDs.UutienId = TblMucgiamuutiennam.UutienId INNER JOIN "
 + "                                                                       TblDm_Thudaunam ON TblMucgiamuutiennam.ThudaunamId = TblDm_Thudaunam.Id "
 + "                                                WHERE      (TblMucgiamuutiennam.ThudaunamId = @ThudaunamId)) AS TblDsLop_Dinhmucgian_phainop)  "
 + "                       AS TblDsLopphainop LEFT OUTER JOIN "
 + "                       TblTrephaithunam ON TblDsLopphainop.NamtrehocId = TblTrephaithunam.NamtrehocId "
 + " if(@Varvalue =4) -- Maugiao "
 + " SELECT     TblDsLopphainop.NamtrehocId, TblTrephaithunam.Id, TblDsLopphainop.LophocId, TblDsLopphainop.Hovaten, TblDsLopphainop.Tenthuonggoi,  "
 + "                       TblDsLopphainop.ThudaunamId, TblDsLopphainop.Mucthu_Maugiao AS Mucthu, TblDsLopphainop.Maugiao_Duocgiam AS Duocgiam,  "
 + "                       TblDsLopphainop.Maugiao_Phainop AS Phainop, ISNULL(TblTrephaithunam.Danop, 0) AS Danop, ISNULL(TblTrephaithunam.Conlai, 0)  "
 + "                       AS Conlai, ISNULL(TblTrephaithunam.Nopthem, 0) AS Nopthem "
 + " FROM         (SELECT     NamtrehocId, LophocId, Hovaten, Tenthuonggoi, UutienId, ThudaunamId, Dinhmucgiam * Dm_Nhomchao / 100 AS Nhomchao_Duocgiam,  "
 + "                                               Dinhmucgiam * Dm_Nhombot / 100 AS Nhombot_Duocgiam, Dinhmucgiam * Dm_Nhatre / 100 AS Nhatre_Duocgiam,  "
 + "                                               Dinhmucgiam * Dm_Maugiao / 100 AS Maugiao_Duocgiam, Dm_Nhomchao AS Mucthu_Nhomchao, Dm_Nhombot AS Mucthu_Nhombot,  "
 + "                                               Dm_Maugiao AS Mucthu_Maugiao, Dm_Nhatre AS Mucthu_Nhatre,  "
 + "                                               Dm_Nhomchao - Dinhmucgiam * Dm_Nhomchao / 100 AS Nhomchao_Phainop,  "
 + "                                               Dm_Nhombot - Dinhmucgiam * Dm_Nhombot / 100 AS Nhombot_Phainop,  "
 + "                                               Dm_Maugiao - Dinhmucgiam * Dm_Maugiao / 100 AS Maugiao_Phainop,  "
 + "                                               Dm_Nhatre - Dinhmucgiam * Dm_Nhatre / 100 AS Nhatre_Phainop "
 + "                        FROM          (SELECT     TblDs.NamtrehocId, TblDs.LophocId, TblDs.Hovaten, TblDs.Tenthuonggoi, TblDs.UutienId,  "
 + "                                                                       TblMucgiamuutiennam.ThudaunamId, ISNULL(TblMucgiamuutiennam.Dinhmucgiam, 0) AS Dinhmucgiam,  "
 + "                                                                       ISNULL(TblDm_Thudaunam.Dm_Nhomchao, 0) AS Dm_Nhomchao, ISNULL(TblDm_Thudaunam.Dm_Nhombot, 0)  "
 + "                                                                       AS Dm_Nhombot, ISNULL(TblDm_Thudaunam.Dm_Maugiao, 0) AS Dm_Maugiao,  "
 + "                                                                       ISNULL(TblDm_Thudaunam.Dm_Nhatre, 0) AS Dm_Nhatre "
 + "                                                FROM          (SELECT     TblNamtrehoc.Id AS NamtrehocId, TblNamtrehoc.LophocId, TblTre.Hovaten, TblTre.Tenthuonggoi,  "
 + "                                                                                               TblTre.UutienId, TblDm_Khoilop.Tenkhoilop "
 + "                                                                        FROM          TblTre INNER JOIN "
 + "                                                                                               TblNamtrehoc ON TblTre.Id = TblNamtrehoc.TreId INNER JOIN "
 + "                                                                                               TblLop ON TblNamtrehoc.LophocId = TblLop.Id INNER JOIN "
 + "                                                                                               TblDm_Phanloailop ON TblLop.PhanloailopId = TblDm_Phanloailop.Id INNER JOIN "
 + "                                                                                               TblDm_Khoilop ON TblDm_Phanloailop.KhoilopID = TblDm_Khoilop.Id "
 + "                                                                        WHERE      (TblLop.Tenlop LIKE N'%' + @Tenlop + N'%') AND (TblNamtrehoc.NamhocId = ?))  "
 + "                                                                       AS TblDs INNER JOIN "
 + "                                                                       TblMucgiamuutiennam ON TblDs.UutienId = TblMucgiamuutiennam.UutienId INNER JOIN "
 + "                                                                       TblDm_Thudaunam ON TblMucgiamuutiennam.ThudaunamId = TblDm_Thudaunam.Id "
 + "                                                WHERE      (TblMucgiamuutiennam.ThudaunamId = @ThudaunamId)) AS TblDsLop_Dinhmucgian_phainop)  "
 + "                       AS TblDsLopphainop LEFT OUTER JOIN "
 + "                       TblTrephaithunam ON TblDsLopphainop.NamtrehocId = TblTrephaithunam.NamtrehocId ";
        public static string SPROC_TBLTREPHAITHUNAM_DELETEBYNAMHOCID = "	delete   "
 + " FROM         TblTrephaithunam  "
 + " WHERE     (Id in (SELECT     TblTrephaithunam.Id "
 + " FROM         TblTrephaithunam INNER JOIN "
 + "                       TblNamtrehoc ON TblTrephaithunam.NamtrehocId = TblNamtrehoc.Id "
 + " WHERE     (TblNamtrehoc.NamhocId = ?))) ";
        public static string SPROC_TBLTREPHAITHUNAM_GET = "declare @SQL nvarchar (2000)"
 + " set @SQL = 'select ROW_NUMBER() OVER (ORDER BY tenthuonggoi) AS STT, NamtrehocId,LophocId,Id, ThudaunamId, Hovaten, Tenthuonggoi, "
 + " 				isnull(Mucthu, 0) as Mucthu, isnull(Duocgiam, (SELECT Dinhmucgiam "
 + " 																FROM vwDinhmucgiamNam "
 + " 																WHERE vwDinhmucgiamNam.ThudaunamId = ' + convert(nvarchar(10), @ThudaunamId) + '  and vwDinhmucgiamNam.NamtrehocId = tbl.NamtrehocId))as Duocgiam,  "
 + " 				isnull(Phainop, 0)as Phainop, Danop, isnull(Conlai, 0)as Conlai, isnull(Nopthem, 0)as Nopthem "
 + " 			from "
 + " 				(SELECT     tbltrenamhoc.NamtrehocId, tbltrenamhoc.LophocId, tbltrenamhoc.Hovaten, tbltrenamhoc.Tenthuonggoi, tbltrenamhoc.TreId, tbltrenamhoc.NamhocId,  "
 + "                       tbltrenamhoc.Tinhtrang, tbltrenamhoc.thudaunamid, TblTrephaithunam.Id, (SELECT     Mucthu "
 + "                             FROM          vwMucthuNam "
 + "                             WHERE      (NamtrehocId = tbltrenamhoc.NamtrehocId) AND (ThutheonamID = ' + convert(nvarchar(10), @ThudaunamId) + ')) Mucthu, TblTrephaithunam.Duocgiam,  "
 + "                       TblTrephaithunam.Phainop, TblTrephaithunam.Danop, TblTrephaithunam.Conlai, TblTrephaithunam.Nopthem "
 + " FROM         (SELECT     NamtrehocId, LophocId, Hovaten, Tenthuonggoi, TreId, NamhocId, Tinhtrang, ' + convert(nvarchar(10), @ThudaunamId) + ' AS thudaunamid "
 + "                        FROM          Vw_Tre_namtrehoc) AS tbltrenamhoc LEFT OUTER JOIN "
 + "                       TblTrephaithunam ON tbltrenamhoc.NamtrehocId = TblTrephaithunam.NamtrehocId AND  "
 + "                       tbltrenamhoc.thudaunamid = TblTrephaithunam.ThudaunamId "
 + " 				WHERE  tbltrenamhoc.NamhocId = ' + convert(nvarchar(10), ?) + ' ' "
 + " if (@status=1) "
 + " 	set @SQL = @SQL + ' and TblTrephaithunam.Danop > 0' "
 + " else if (@status=2) "
 + " 	set @SQL = @SQL + ' and (TblTrephaithunam.Danop = 0 or TblTrephaithunam.Danop is null)' "
 + " if(@LophocId!=0) "
 + " 	Set @SQL = @SQL + ' AND tbltrenamhoc.LophocId = ' + convert(nvarchar(10), @LophocId) "
 + " if(@tenTre!='') "
 + " 	Set @SQL = @SQL + ' AND (tbltrenamhoc.Hovaten LIKE N'+ char(39)+ char(37) + @tentre + + char(37)+ char(39)+ ') ' "
 + " set @SQL = @SQL + ') as tbl where  tbl.ThudaunamId = ' + convert(nvarchar(10), @ThudaunamId) + ' or tbl.ThudaunamId is null' "
 + "  print @SQL "
 + " exec (@SQL) ";
        public static string SPROC_TBLTREPHAITHUNAM_GETDINHMUCGIAMBY_NAMTREHOCID = "SELECT     TblMucgiamuutiennam.Dinhmucgiam, TblNamtrehoc.Id AS NamtrehocId"
 + " FROM         TblTre INNER JOIN "
 + "                       TblNamtrehoc ON TblTre.Id = TblNamtrehoc.TreId INNER JOIN "
 + "                       TblDm_Uutien ON TblTre.UutienId = TblDm_Uutien.Id INNER JOIN "
 + "                       TblMucgiamuutiennam ON TblDm_Uutien.Id = TblMucgiamuutiennam.UutienId "
 + " WHERE (TblNamtrehoc.Id = @NamtrehocId)AND (TblMucgiamuutiennam.ThudaunamId = @ThudaunamId) ";
        public static string SPROC_TBLTREPHAITHUNAM_UPDATE = "UPDATE TblTrephaithunam"
 + " SET Mucthu = ?, Duocgiam = ?, "
 + " 	Phainop = ?, Danop = ?, "
 + " 	Conlai = ?, Nopthem = ? "
 + " WHERE Id = ?";
        public static string SPROC_TBLTREPHAITHUTHANG = "	declare @khoilop int"
 + " 	declare @mucthu float "
 + " 	SELECT     @khoilop=TblDm_Khoilop.Id "
 + " 	FROM         TblLop INNER JOIN "
 + " 						  TblDm_Phanloailop ON TblLop.PhanloailopId = TblDm_Phanloailop.Id INNER JOIN "
 + " 						  TblDm_Khoilop ON TblDm_Phanloailop.KhoilopID = TblDm_Khoilop.Id "
 + " 	WHERE     (TblLop.Id = @LophocId) "
 + " 	if (@khoilop=1) "
 + " 			SELECT    @mucthu = Phi_Nhatre "
 + " 			FROM         TblDm_Thutheothang "
 + " 			WHERE     (Id = @ThutheothangId) "
 + " 	else "
 + " 			SELECT    @mucthu = Phi_Maugiao "
 + " 			FROM         TblDm_Thutheothang "
 + " 			WHERE     (Id = @ThutheothangId) "
 + " 	SELECT     distinct ROW_NUMBER() OVER (ORDER BY tenthuonggoi) AS STT, Vw_Tre_namtrehoc.NamtrehocId, Vw_Tre_namtrehoc.LophocId, "
 + " 				id='', ThutheothangId = @ThutheothangId, Vw_Tre_namtrehoc.Hovaten, Vw_Tre_namtrehoc.Tenthuonggoi,  "
 + " 				Mucthu=@mucthu, (SELECT Dinhmucgiam "
 + " 								FROM vwDinhmucuutien "
 + " 								WHERE NamtrehocId = Vw_Tre_namtrehoc.NamtrehocId and ThutheothangId = @ThutheothangId) as Duocgiam, Phainop = 0, Danop=0, Conlai=0, Nopthem=0, thamgia=0 "
 + " 	FROM         Vw_Tre_namtrehoc LEFT OUTER JOIN "
 + " 						  TblTrephaithuthang ON Vw_Tre_namtrehoc.NamtrehocId = TblTrephaithuthang.NamtrehocId "
 + " 	WHERE     (Vw_Tre_namtrehoc.NamhocId = ?) AND (Vw_Tre_namtrehoc.LophocId = @LophocId) ";
        public static string SPROC_TBLTREPHAITHUTHANG_ADD = "	INSERT INTO TblTrephaithuthang"
 + " 	( "
 + " 		NamtrehocId, "
 + " 		ThutheothangId, "
 + " 		Mucthu, "
 + " 		Duocgiam, "
 + " 		Phainop, "
 + " 		Danop, "
 + " 		Conlai, "
 + " 		Nopthem, "
 + " 	Thamgia  "
 + " 	) "
 + " 	VALUES "
 + " 	( "
 + " 		@NamtrehocId, "
 + " 		@ThutheothangId, "
 + " 		@Mucthu, "
 + " 		@Duocgiam, "
 + " 		@Phainop, "
 + " 		@Danop, "
 + " 		@Conlai, "
 + " 		@Nopthem, "
 + " 	@Thamgia "
 + " 	) ";
        public static string SPROC_TBLTREPHAITHUTHANG_DELETEBYNAMHOCID = "	delete   "
 + " FROM         TblTrephaithuthang  "
 + " WHERE     (Id in (SELECT     TblTrephaithuthang.Id "
 + " FROM         TblTrephaithuthang INNER JOIN "
 + "                       TblNamtrehoc ON TblTrephaithuthang.NamtrehocId = TblNamtrehoc.Id "
 + " WHERE     (TblNamtrehoc.NamhocId = ?))) ";
        public static string SPROC_TBLTREPHAITHUTHANG_GET = "declare @SQL nvarchar (2000)"
 + " set @SQL = 'select ROW_NUMBER() OVER (ORDER BY tenthuonggoi) AS STT, NamtrehocId,LophocId,Id, ThutheothangId, Hovaten, Tenthuonggoi, "
 + " 				isnull(Mucthu, 0) as Mucthu, isnull(Duocgiam, (SELECT Dinhmucgiam "
 + " 										FROM vwDinhmucuutien "
 + " 										WHERE NamtrehocId = tbl.NamtrehocId and ThutheothangId = ' + convert(nvarchar(10), @ThutheothangID) + '))as Duocgiam,  "
 + " 				isnull(Phainop, 0)as Phainop, Danop, isnull(Conlai, 0)as Conlai,isnull(Nopthem, 0)as Nopthem, "
 + " 				isnull(Thamgia, 0)as Thamgia "
 + " 			from "
 + " 				(SELECT     tbltrenamhoc.Hovaten, tbltrenamhoc.Tenthuonggoi, tbltrenamhoc.NamtrehocId AS NamtrehocId, tbltrenamhoc.TreId, tbltrenamhoc.LophocId,  "
 + "                       tbltrenamhoc.NamhocId, tbltrenamhoc.Tinhtrang, tbltrenamhoc.ThutheothangID AS ThutheothangID, TblTrephaithuthang.Id,  "
 + "                       TblTrephaithuthang.Duocgiam, TblTrephaithuthang.Phainop, TblTrephaithuthang.Danop, TblTrephaithuthang.Conlai,  "
 + "                       TblTrephaithuthang.Nopthem, TblTrephaithuthang.Thamgia, (select mucthu from vwmucthuthang where namtrehocid = tbltrenamhoc.namtrehocid and thutheothangid=' + convert(nvarchar(10), @ThutheothangID) + ') as Mucthu "
 + " 				FROM         (SELECT     Hovaten, Tenthuonggoi, NamtrehocId, TreId, LophocId, NamhocId, Tinhtrang, ' + convert(nvarchar(10), @ThutheothangID) + ' AS ThutheothangID "
 + " 							   FROM          Vw_Tre_namtrehoc) AS tbltrenamhoc LEFT OUTER JOIN "
 + " 							  TblTrephaithuthang ON tbltrenamhoc.NamtrehocId = TblTrephaithuthang.NamtrehocId AND  "
 + " 							  tbltrenamhoc.ThutheothangID = TblTrephaithuthang.ThutheothangId "
 + " 				WHERE     tbltrenamhoc.NamhocId = ' + convert(nvarchar(10), ?) + ' ' "
 + " if (@status=1) "
 + " 	set @SQL = @SQL + ' and TblTrephaithuthang.Danop > 0' "
 + " else if (@status=2) "
 + " 	set @SQL = @SQL + ' and (TblTrephaithuthang.Danop = 0 or TblTrephaithuthang.Danop is null)' "
 + " if(@LophocId!=0) "
 + " 	Set @SQL = @SQL + ' AND tbltrenamhoc.LophocId = ' + convert(nvarchar(10), @LophocId)  "
 + " if(@tenTre!='') "
 + " 	Set @SQL = @SQL + ' AND (tbltrenamhoc.Hovaten LIKE N'+ char(39)+ char(37) + @tentre + + char(37)+ char(39)+ ') ' "
 + " set @SQL = @SQL + ') as tbl where  tbl.ThutheothangId = ' + convert(nvarchar(10), @ThutheothangID) + ' or tbl.ThutheothangId is null' "
 + " print @SQL "
 + " exec (@SQL) ";
        public static string SPROC_TBLTREPHAITHUTHANG_GETBYID = "SELECT"
 + " * "
 + " FROM TblTrephaithuthang "
 + " WHERE Id =?";
        public static string SPROC_TBLTREPHAITHUTHANG_UPDATE = "UPDATE TblTrephaithuthang"
 + " SET Mucthu = @Mucthu, "
 + " 	Duocgiam = @Duocgiam, "
 + " 	Phainop = @Phainop, "
 + " 	Danop = @Danop, "
 + " 	Conlai = @Conlai, "
 + " 	Nopthem = @Nopthem, "
 + " 	Thamgia =@Thamgia "
 + " WHERE Id =?";
        public static string SPROC_TBLTREPHAITHUTHANG_DEL = "Delete from TblTrephaithuthang WHERE Id = ?";
        public static string SPROC_TBLTREPHAITHUTHANGBYTHUTHEOTHANGID = "SELECT     Id, NamtrehocId, ThutheothangId, Mucthu, Duocgiam, Phainop, Danop, Conlai, Nopthem, Thamgia"
 + " FROM         TblTrephaithuthang "
 + " WHERE     (ThutheothangId = @ThutheothangId) ";
        public static string SPROC_TBLTRETHUTUNGUYEN_DELETEBYNAMHOCID = "	delete   "
 + " FROM        TblTrenoptunguyen "
 + " WHERE     (Id in (SELECT     TblTrenoptunguyen.Id "
 + " FROM         TblTrenoptunguyen INNER JOIN "
 + "                       TblNamtrehoc ON TblTrenoptunguyen.NamtrehocId = TblNamtrehoc.Id "
 + " WHERE     (TblNamtrehoc.NamhocId = ?))) ";
        public static string SPROC_TBLTRUONG_ADD = "	INSERT INTO TblTruong"
 + " 	( "
 + " 		LoaitruongId, "
 + " 		LoaitruongchuanId, "
 + " 		TensoGD, "
 + " 		TenphongGD, "
 + " 		Tentruong, "
 + " 		Diachi, "
 + " 		IdXa, "
 + " 		Dienthoai, "
 + " 		Email, "
 + " 		Web, "
 + " Vungmien  "
 + " 	) "
 + " 	VALUES "
 + " 	( "
 + " 		@LoaitruongId, "
 + " 		@LoaitruongchuanId, "
 + " 		@TensoGD, "
 + " 		@TenphongGD, "
 + " 		@Tentruong, "
 + " 		@Diachi, "
 + " 		@IdXa, "
 + " 		@Dienthoai, "
 + " 		@Email, "
 + " 		@Web, "
 + " @Vungmien "
 + " 	) ";
        public static string SPROC_TBLTRUONG_GET = "SELECT"
 + " TblTruong.Id, TblTruong.LoaitruongId, TblTruong.LoaitruongchuanId,  "
 + " TblTruong.TensoGD, TblTruong.TenphongGD, TblTruong.Tentruong, TblTruong.Diachi, TblTruong.Idxa, "
 + " TblTruong.Dienthoai, "
 + " TblTruong.Email, TblTruong.Web, TblTruong.Vungmien ,Quyetdinhtl,dunuocsach, noimang,TblTruong.Dientich, TblDm_Huyen.TinhId, TblDm_Xa.HuyenId "
 + " FROM ((TblTruong left join TblDm_Xa on TblTruong.IdXa = TblDm_Xa.Id) "
 + " LEFT join TblDm_Huyen on TblDm_Xa.HuyenId = TblDm_Huyen.Id) "
 + " LEFT join TblDm_Tinh on TblDm_Huyen.TinhId = TblDm_Tinh.Id ";
        public static string SPROC_TBLTRUONG_UPDATE = "UPDATE TblTruong"
 + " SET "
 + " 	LoaitruongId = @LoaitruongId, "
 + " 	LoaitruongchuanId = @LoaitruongchuanId, "
 + " 	TensoGD = '@TensoGD', "
 + " 	TenphongGD = '@TenphongGD', "
 + " 	Tentruong = \"@Tentruong\", "
 + " 	Diachi = \"@Diachi\", "
 + " 	IdXa = @IdXa, "
 + " 	Dienthoai = '@Dienthoai', "
 + " 	Email = '@Email', "
 + " 	Web = '@Web', "
 + " Vungmien= @Vungmien , "
 + " Quyetdinhtl= @qdtl , "
  + " Dunuocsach= @Dunuocsach , "
 + " Noimang= @Noimang,  "
  + " Dientich= @Dientich  "
 + " WHERE "
 + " 	Id =@Id";
        public static string SPROC_TBLXEPLOAINHANVIEN = "SELECT     TblXeploaiky.Id, TblNhanvien.Hotendem, TblNhanvien.Ten, TblNhanvien.Gioitinh, TblNhanviencongtac.ToId, "
 + "                       TblXeploaiky.NhanviencongtacId, TblXeploaiky.HockyId, TblXeploaiky.Ketqua, TblXeploaiky.NamhocId "
 + " FROM         (TblXeploaiky INNER JOIN "
 + "                       TblNhanviencongtac ON TblXeploaiky.NhanviencongtacId = TblNhanviencongtac.Id) INNER JOIN "
 + "                       TblNhanvien ON TblNhanviencongtac.NhanvienId = TblNhanvien.Id "
 + " WHERE     (TblNhanviencongtac.ToId = @ToId) AND (TblXeploaiky.HockyId = @HockyId) AND (TblXeploaiky.NamhocId = @NamhocId) "
 + " and (TblXeploaiky.Xeploaitheo =@Xeploaitheo)  AND (TblNhanvien.Trangthai = 0) ";
        public static string SPROC_TBLXEPLOAINHANVIEN_ADD = "	INSERT INTO TblXeploaiky"
 + " 	( "
 + " 		NhanviencongtacId, "
 + " 	HockyId ,  "
 + " 	NamhocId , "
 + " Xeploaitheo "
 + " 	) "
 + " 	VALUES "
 + " 	( "
 + " 		@NhanviencongtacId , "
 + " 	@HockyId ,  "
 + " 	?, "
 + " @Xeploaitheo "
 + " 	) ";
        public static string SPROC_TBLXEPLOAINHANVIEN_BYKETQUA = "	SELECT     HockyId, Xeploai, NamhocId"
 + " FROM         Tbl_Totrongnam "
 + " WHERE     (Xeploai LIKE '@Ketqua') ";
        public static string SPROC_TBLXEPLOAINHANVIEN_UPDATE = "	UPDATE TblXeploaiky"
 + "    SET Ketqua = '@Ketqua' "
 + "  WHERE Id = @Id ";
        public static string SPROC_TBLXUATHANGHOA_GETBYNGAYNX = "SELECT     TblNhapxuathanghoa.Thucpham_ThucanId, TblNhapxuathanghoa.DonvitinhId, TblHoadonnhapxuat.NgayNX, "
 + "                       TblThucpham_thucan.Tenthucan, TblDm_Donvitinh.Tendonvitinh, TblNhapxuathanghoa.Soluongcon,  "
 + "                       TblNhapxuathanghoa.Soluong AS Soluong, TblNhapxuathanghoa.Dongia,  "
 + "                       TblNhapxuathanghoa.Dongia * TblNhapxuathanghoa.Soluong AS Thanhtien "
 + " FROM         ((TblHoadonnhapxuat INNER JOIN "
 + "                       TblNhapxuathanghoa ON TblHoadonnhapxuat.Id = TblNhapxuathanghoa.HoadonnhapxuatId) INNER JOIN "
 + "                       TblThucpham_thucan ON TblNhapxuathanghoa.Thucpham_ThucanId = TblThucpham_thucan.Id) INNER JOIN "
 + "                       TblDm_Donvitinh ON TblThucpham_thucan.DonvitinhId = TblDm_Donvitinh.Id "
 + " WHERE     (TblHoadonnhapxuat.Trangthai = 0) AND (TblHoadonnhapxuat.NgayNX = @NgayNX) ";
        public static string SPROC_TBLXUATHANGHOAGIATRUNGBINH_ADD = "	INSERT INTO TblXuathanghoagiatrungbinh"
 + " 	( "
 + " 		HoadonnhapxuatId, "
 + " 		DonvitinhId, "
 + " 		Thucpham_ThucanId, "
 + " 		Dongia, "
 + " 		Soluong, "
 + " 		Soluongcon, "
 + " 		Thanhtien "
 + " 	) "
 + " 	VALUES "
 + " 	( "
 + " 		@HoadonnhapxuatId, "
 + " 		@DonvitinhId, "
 + " 		?, "
 + " 		@Dongia, "
 + " 		?, "
 + " 		?con, "
 + " 		@Thanhtien "
 + " 	) ";
        public static string SPROC_TBLXUATHANGHOAGIATRUNGBINH_DELEBYHOADON = "DELETE FROM TblXuathanghoagiatrungbinh where HoadonnhapxuatId =@HoadonnhapxuatId";
        public static string SPROC_TBLXUATHANGHOAGIATRUNGBINH_GETBYNGAYNX = "	SELECT     TblXuathanghoagiatrungbinh.DonvitinhId, TblXuathanghoagiatrungbinh.Thucpham_ThucanId, TblXuathanghoagiatrungbinh.Dongia, "
 + "                       TblXuathanghoagiatrungbinh.Soluong, TblXuathanghoagiatrungbinh.Soluongcon, TblXuathanghoagiatrungbinh.Thanhtien,  "
 + "                       TblThucpham_thucan.Tenthucan, TblDm_Donvitinh.Tendonvitinh, TblHoadonnhapxuat.NgayNX as Ngay "
 + " FROM         TblXuathanghoagiatrungbinh INNER JOIN "
 + "                       TblHoadonnhapxuat ON TblXuathanghoagiatrungbinh.HoadonnhapxuatId = TblHoadonnhapxuat.Id INNER JOIN "
 + "                       TblDm_Donvitinh ON TblXuathanghoagiatrungbinh.DonvitinhId = TblDm_Donvitinh.Id INNER JOIN "
 + "                       TblThucpham_thucan ON TblXuathanghoagiatrungbinh.Thucpham_ThucanId = TblThucpham_thucan.Id "
 + " WHERE     (TblHoadonnhapxuat.Trangthai = 0) AND (TblHoadonnhapxuat.NgayNX = @NgayNX) ";
        public static string SPROC_TONGHOPHANGTONKHO = "SELECT     View_Tonkho.Thucpham_ThucanId, TblThucpham_thucan.Tenthucan, View_Tonkho.Soluong AS Soluongton, "
 + "                       TblDm_Donvitinh.Tendonvitinh "
 + " FROM         (TblDm_Donvitinh INNER JOIN "
 + "                       TblThucpham_thucan ON TblDm_Donvitinh.Id = TblThucpham_thucan.DonvitinhId) INNER JOIN "
 + "                       View_Tonkho ON TblThucpham_thucan.Id = View_Tonkho.Thucpham_ThucanId "
 + " WHERE     (View_Tonkho.Soluong <> 0) ";
        public static string SPROC_TONGHOPHANGTONKHO_FINDNAME = "SELECT     View_Tonkho.Thucpham_ThucanId, TblThucpham_thucan.Tenthucan, View_Tonkho.Soluong AS Soluongton, "
 + "                       TblDm_Donvitinh.Tendonvitinh "
 + " FROM         (TblDm_Donvitinh INNER JOIN "
 + "                       TblThucpham_thucan ON TblDm_Donvitinh.Id = TblThucpham_thucan.DonvitinhId) INNER JOIN "
 + "                       View_Tonkho ON TblThucpham_thucan.Id = View_Tonkho.Thucpham_ThucanId "
 + " WHERE     (View_Tonkho.Soluong <> 0 and TblThucpham_thucan.Tenthucan like '%@Name%') ";


        public static string sproc_Tonghophangtonkho_FindNameandNgayNX = " SELECT     View_Tonkho.Thucpham_ThucanId,TblThucpham_thucan.Tenthucan, Round(View_Tonkho.Soluong,10) AS Soluongton, " +
                      " TblDm_Donvitinh.Tendonvitinh FROM        ( TblThucpham_thucan INNER JOIN " +
                     " TblDm_Donvitinh ON TblThucpham_thucan.DonvitinhId = TblDm_Donvitinh.Id) INNER JOIN ( " +
" SELECT     SUM(TblNhapxuathanghoa.Soluong) AS Soluong, TblNhapxuathanghoa.Thucpham_ThucanId " +
    " FROM   ( SELECT     Dongia, Soluong, Thucpham_ThucanId, NgayNX " +
           " FROM          View_Nhaphanghoa WHERE      (NgayNX <= @NgayNX) UNION ALL SELECT     Dongia, Soluong, Thucpham_ThucanId, NgayNX FROM        View_Xuathanghoa "
+ " WHERE     (NgayNX <= @NgayNX) ) AS TblNhapxuathanghoa GROUP BY TblNhapxuathanghoa.Thucpham_ThucanId HAVING      (SUM(TblNhapxuathanghoa.Soluong) <> 0) " +
" ) AS View_Tonkho ON TblThucpham_thucan.Id = View_Tonkho.Thucpham_ThucanId WHERE     (TblThucpham_thucan.Tenthucan LIKE '%' + '@Name' + '%') and Round(View_Tonkho.Soluong,10) >0 ";


        public static string SPROC_TONGHOPHOADONDICHOBYNGAY = "SELECT     TblNhapxuathanghoa.Thucpham_ThucanId, TblThucpham_thucan.Tenthucan, TblDm_Donvitinh.Tendonvitinh, "
 + "                       TblNhapxuathanghoa.Soluong AS Soluongcon, TblNhapxuathanghoa.Soluong AS Soluong, TblNhapxuathanghoa.Dongia,  "
 + "                       TblNhapxuathanghoa.DonvitinhId, TblNhapxuathanghoa.Soluong * TblNhapxuathanghoa.Dongia AS Thanhtien "
 + " FROM         TblHoadonnhapxuat INNER JOIN "
 + "                       TblNhapxuathanghoa ON TblHoadonnhapxuat.Id = TblNhapxuathanghoa.HoadonnhapxuatId INNER JOIN "
 + "                       TblThucpham_thucan ON TblNhapxuathanghoa.Thucpham_ThucanId = TblThucpham_thucan.Id INNER JOIN "
 + "                       TblDm_Donvitinh ON TblThucpham_thucan.DonvitinhId = TblDm_Donvitinh.Id "
 + " WHERE     (TblHoadonnhapxuat.Trangthai = 1) AND (TblHoadonnhapxuat.NgayNX = @NgayNX) "
 + " GROUP BY TblNhapxuathanghoa.Dongia, TblNhapxuathanghoa.Thucpham_ThucanId, TblThucpham_thucan.Tenthucan,  "
 + "                       TblDm_Donvitinh.Tendonvitinh, TblNhapxuathanghoa.DonvitinhId, TblNhapxuathanghoa.Soluong ";
        public static string STOREDPROCEDURE3 = "	 			 SELECT     Id AS IDBaoAn, Ngay AS NgayBaoAn, Tongsosuat, Tongsotre, LophocId"
 + " 	 			 FROM         TblBaoan "
 + " 	 			 WHERE     (Ngay = @ngayBaoAn) AND (LophocId = @LopId) ";
        public static string TBLDM_BENHLY_DEL = "delete    "
 + " FROM        TblDm_Benhly "
 + " WHERE     (Id = @Id) ";
        public static string TBLDM_BENHLY_EDITPRC = "	update TblDm_Benhly set Tenbenh = '@Tenbenh', Muagap ='@Muagap', Trieuchung ='@Trieuchung', Cachxuly ='@Cachxuly' where (Id =@Id)";
        public static string TBLDM_BENHLY_FINDNAMESAMEPRC = "	" + " 	select * from TblDm_Benhly where  (Tenbenh = '@Tenbenh'  ) ";
        public static string TBLDM_BENHLY_INSERTPRC = "	insert into TblDm_Benhly(Tenbenh, Muagap, Trieuchung,Cachxuly) values('@Tenbenh', '@Muagap', '@Trieuchung', '@Cachxuly')";
        public static string TBLDM_BENHLY_SELECTALL_PRC = "	select * from TblDm_Benhly"
 + " ORDER BY Tenbenh ";
        public static string TBLDM_BUAANTRONGNGAY_BYID = "select * from TblDm_Buaantrongngay where Id =@Id";
        public static string TBLDM_BUAANTRONGNGAY_DEL = "delete "
 + " FROM TblDm_Buaantrongngay "
 + " WHERE Id =?";
        public static string TBLDM_BUAANTRONGNGAY_EDITPRC = "update TblDm_Buaantrongngay set Tenbuaan =@Tenbuaan, Phanbotienan = @Phanbotienan where(Id =@Id)";
        public static string TBLDM_BUAANTRONGNGAY_FINDNAMESAMEPRC = "select  * from TblDm_Buaantrongngay where (Tenbuaan = ? ) ";
        public static string TBLDM_BUAANTRONGNGAY_INSERTPRC = "	Insert into TblDm_Buaantrongngay(Tenbuaan, Phanbotienan) Values(@Tenbuaan, @Phanbotienan)";
        public static string TBLDM_BUAANTRONGNGAY_SELECTALL_PRC = "select * from TblDm_Buaantrongngay ORDER BY id ";
        public static string TBLDM_CAPXAYDUNG_DEL = "delete "
 + " FROM TblDm_Capxaydung "
 + " WHERE     (Id = @Id) ";
        public static string TBLDM_CAPXAYDUNG_EDITPRC = "update TblDm_Capxaydung set Tencapxaydung ='@Tencapxaydung' where(Id =@Id)"
;
        public static string TBLDM_CAPXAYDUNG_FINDNAMESAMEPRC = "" + " select * from TblDm_Capxaydung where (Tencapxaydung = '@Ten' ) ";
        public static string TBLDM_CAPXAYDUNG_INSERTPRC = "	insert into TblDm_Capxaydung(Tencapxaydung) values('@Tencapxaydung')";
        public static string TBLDM_CAPXAYDUNG_SELECTALL_PRC = "	select Id, Tencapxaydung from TblDm_Capxaydung"
 + " ORDER BY Tencapxaydung ";

        public static string TBLDM_CHITIETBUAAN = "	";
        public static string TBLDM_CHUCVU_EDITPRC = "update TblDm_Chucvu set Tenchucvu=@Tenchucvu, PhanloaicanboId=@PhanloaicanboId where (Id=@Id)";
        public static string TBLDM_CHUCVU_FINDNAMESAMEPRC = "select * from TblDm_Chucvu where Tenchucvu = @VarName ";
        public static string TBLDM_CHUCVU_INSERTPRC = "insert into TblDm_Chucvu(Tenchucvu, PhanloaicanboId) values(@Tenchucvu,@PhanloaicanboId)";
        public static string TBLDM_CHUCVU_SELECTALL_PRC = "	select * from TblDm_Chucvu where PhanloaicanboId = @PhanloaicanboId ORDER BY Tenchucvu ";

        public static string TBLDM_DANTOC_DEL = "delete  from TblDm_Dantoc where  (Id = ?) ";
        public static string TBLDM_DANTOC_EDITPRC = "update TblDm_Dantoc set Tendantoc = '@Tendantoc', Thieuso =@Thieuso where(Id = @Id)";
        public static string TBLDM_DANTOC_FINDNAMESAMEPRC = "select * from TblDm_Dantoc where (Tendantoc = ? ) ";
        public static string TBLDM_DANTOC_INSERTPRC = "	insert into TblDm_Dantoc(Tendantoc, thieuso) values(?,?)";
        public static string TBLDM_DANTOC_SELECTALL_PRC = "	select Id, Tendantoc, Thieuso from TblDm_Dantoc ORDER BY Tendantoc ";

        public static string TBLDM_DATCHUAN_DEL = "delete FROM TblDm_Datchuan WHERE (Id = @Id) ";
        public static string TBLDM_DATCHUAN_EDITPRC = "	update TblDm_Datchuan set Tendatchuan = '@Tendatchuan' where (Id = @Id)";
        public static string TBLDM_DATCHUAN_FINDNAMESAMEPRC = "select * from TblDm_Datchuan where (Tendatchuan = '@Tendatchuan')";
        public static string TBLDM_DATCHUAN_INSERTPRC = "insert into TblDm_Datchuan(Tendatchuan) values('@Tendatchuan')";
        public static string TBLDM_DATCHUAN_SELECTALL_PRC = "select * from TblDm_Datchuan ORDER BY Tendatchuan ";

        public static string TBLDM_DONVITINH_DEL = "delete  from TblDm_Donvitinh where  (Id = ?) ";
        public static string TBLDM_DONVITINH_EDITPRC = "update TblDm_Donvitinh set Tendonvitinh = ? where ( Id = ? )";
        public static string TBLDM_DONVITINH_FINDNAMESAMEPRC = "select * from TblDm_donvitinh where (tendonvitinh =?  )";
        public static string TBLDM_DONVITINH_INSERTPRC = "	insert into TblDm_Donvitinh(Tendonvitinh) values(?)";
        public static string TBLDM_DONVITINH_SELECTALL_PRC = "	select * from TblDm_Donvitinh ORDER BY Tendonvitinh";
        public static string TBLDM_DONVITINH_SELECTBYNAME = "	 if @option =1 "
 + " 			 SELECT     TblDm_Donvitinh.Tendonvitinh, TblNhapxuathanghoa.Soluongcon, TblDm_Donvitinh.Id, TblThucpham_thucan.Tenthucan,  "
 + " 			                       TblThucpham_thucan.Id AS IdMonAn, TblNhapxuathanghoa.Id AS Id_HoaDon, TblNhapxuathanghoa.Dongia "
 + " 			 FROM         TblDm_Donvitinh INNER JOIN "
 + " 			                       TblThucpham_thucan ON TblDm_Donvitinh.Id = TblThucpham_thucan.DonvitinhId INNER JOIN "
 + " 			                       TblNhapxuathanghoa ON TblDm_Donvitinh.Id = TblNhapxuathanghoa.DonvitinhId AND  "
 + " 			                       TblThucpham_thucan.Id = TblNhapxuathanghoa.Thucpham_ThucanId "
 + " 			 WHERE     (TblThucpham_thucan.Tenthucan = @tenThucPham) "
 + " 			 ORDER BY TblNhapxuathanghoa.Dongia DESC "
 + " 	 if @option =2  "
 + " 			SELECT     TblDm_Donvitinh.Tendonvitinh, TblDm_Donvitinh.Id, TblThucpham_thucan.Id AS IdMonAn, TblThucpham_thucan.Tylequydoi,  "
 + " 			                      TblThucpham_thucan.Tylethai, TblThucpham_thucan.Calo "
 + " 			FROM         TblDm_Donvitinh INNER JOIN "
 + " 			                      TblThucpham_thucan ON TblDm_Donvitinh.Id = TblThucpham_thucan.DonvitinhId "
 + " 			WHERE     (TblThucpham_thucan.Tenthucan = @tenThucPham) ";
        public static string TBLDM_DOTUOI_SELECTALL = "SELECT Id, Tenloailop, Cantuoi1, Cantuoi2 FROM TblDm_Phanloailop ";
        public static string TBLDM_HEDAOTAO_DELBYID = "delete FROM TblDm_Hedaotao WHERE (Id = @Id) ";
        public static string TBLDM_HEDAOTAO_FINDNAMESAMEPRC = "select * from TblDm_Hedaotao where (tenhedaotao =@Tenhedaotao) ";
        public static string TBLDM_HOCKY_FINDNAMESAMEPRC = "select * from TblDm_Hocky where (Tenloaiky = '@Tenloaiky' ) ";
        public static string TBLDM_HUYEN_DEL = "delete FROM TblDm_Huyen WHERE (Id = @Id) ";
        public static string TBLDM_HUYEN_EDITPRC = "update TblDm_Huyen set TinhId = @TinhId, Tenhuyen ='@Tenhuyen' where(Id = @Id) ";
        public static string TBLDM_HUYEN_INSERTPRC = "insert into TblDm_Huyen(TinhId, Tenhuyen) values(@TinhId, '@Tenhuyen') ";
        public static string TBLDM_HUYEN_SELECTALL_PRC = "select TblDm_Huyen.Id, TblDm_Huyen.TinhId, TblDm_Huyen.Tenhuyen from TblDm_Huyen inner join TblDm_Tinh on TblDm_Tinh.Id = TblDm_Huyen.TinhId ORDER BY TblDm_Huyen.Tenhuyen ";
        public static string TBLDM_HUYEN_SELECTALLBYTINHID_PRC = "select TblDm_Huyen.Id, TblDm_Huyen.TinhId, TblDm_Huyen.Tenhuyen from TblDm_Huyen inner join TblDm_Tinh on TblDm_Tinh.Id = TblDm_Huyen.TinhId where  TblDm_Huyen.TinhId = @TinhId ORDER BY TblDm_huyen.Tenhuyen ";
        public static string TBLDM_KENH_DEL = "delete FROM TblDm_Kenh WHERE (Id = @Id) ";
        public static string TBLDM_KENH_EDITPRC = "update TblDm_Kenh set Tenkenh = '@Tenkenh', Loaikenh = '@Loaikenh', Kenhchinh='@Kenhchinh' where Id =@Id";
        public static string TBLDM_KENH_FINDNAMESAMEPRC = "	" + " 	select * from TblDm_Kenh where  (Tenkenh ='@Tenkenh'  ) ";
        public static string TBLDM_KENH_INSERTPRC = "insert into TblDm_Kenh( Tenkenh, Loaikenh,Kenhchinh) values( '@Tenkenh', '@Loaikenh','@Kenhchinh')";
        public static string TBLDM_KENH_SELECTALL_PRC = "select * from TblDm_Kenh ORDER BY Tenkenh";
        public static string TBLDM_KHOILOP_FINDNAMESAMEPRC = "select * from TblDm_Khoilop WHERE Tenkhoilop like '%' +@Tenkhoilop+ '%' ";
        public static string TBLDM_KHOILOP_SELECTALL = "SELECT * FROM TblDm_Khoilop ";
        public static string TBLDM_LOAIHINHDAOTAO_FINDNAMESAMEPRC = "select * from TblDm_Loaihinhdaotao where (Tenloaihinhdaotao = '@Tenloaihinhdaotao' ) ";

        public static string TBLDM_LOAIHOPDONG_EDITPRC = "	update TblDm_Loaihopdong set Tenhopdong = @Tenhopdong where (Id = @Id)";
        public static string TBLDM_LOAIHOPDONG_FINDNAMESAMEPRC = "select * from TblDm_Loaihopdong where (Tenhopdong = @VarName) ";
        public static string TBLDM_LOAIHOPDONG_INSERTPRC = "insert into TblDm_Loaihopdong(Tenhopdong) values(@Tenhopdong)";
        public static string TBLDM_LOAIHOPDONG_SELECTALL_PRC = "select Id, Tenhopdong from TblDm_Loaihopdong ORDER BY Tenhopdong ";

        public static string TBLDM_LOAIMON_FINDNAMESAMEPRC = "select * from TblDm_Loaimon where Tenloaimon=? ";

        public static string TBLDM_LOAIPHONGHOC_EDITPRC = "	update TblDm_Loaiphonghoc set Tenloaiphong = '@Tenloaiphong',dientich = @dientich,soluongthieu = @soluongthieu, soluongxaymoi = @soluongxaymoi where (Id = @Id)";
        public static string TBLDM_LOAIPHONGHOC_FINDNAMESAMEPRC = "select * from TblDm_Loaiphonghoc where  (Tenloaiphong  = ?  ) ";
        public static string TBLDM_LOAIPHONGHOC_INSERTPRC = "insert into TblDm_Loaiphonghoc(Tenloaiphong,Dientich,Soluongthieu,Soluongxaymoi,NamhocId) values(@Tenloaiphong,@Dientich,@Sophongthieu,@Sophongxaymoi,@NamhocId)";
        public static string TBLDM_LOAIPHONGHOC_SELECTALL_PRC = "select * from TblDm_Loaiphonghoc where namhocId = @NamhocId";
        public static string SP_LOAIPHONGHOC_DELETE = "DELETE FROM TblDm_Loaiphonghoc WHERE Id =@Id";

        public static string TBLDM_LOAITRUONG_DEL = "delete FROM TblDm_Loaitruong WHERE Id = @Id ";
        public static string TBLDM_LOAITRUONG_EDITPRC = "update TblDm_Loaitruong set Tenloaitruong ='@Tenloaitruong' where(Id =@Id)";
        public static string TBLDM_LOAITRUONG_FINDNAMESAMEPRC = "select * from TblDm_Loaitruong where  (Tenloaitruong = '@Tenloaitruong' ) ";
        public static string TBLDM_LOAITRUONG_INSERTPRC = "insert into TblDm_Loaitruong(Tenloaitruong) values('@Tenloaitruong')";
        public static string TBLDM_LOAITRUONG_SELECTALL_PRC = "select Id, Tenloaitruong from TblDm_Loaitruong ORDER BY Tenloaitruong ";

        public static string TBLDM_LOAITRUONGCHUAN_DEL = "delete FROM TblDm_Loaitruongchuan WHERE Id = ? ";
        public static string TBLDM_LOAITRUONGCHUAN_EDITPRC = "update TblDm_Loaitruongchuan set Tendatchuan = '@Tendatchuan' where (Id =@Id)";
        public static string TBLDM_LOAITRUONGCHUAN_FINDNAMESAMEPRC = "	" + " 	select * from TblDm_Loaitruongchuan where  (Tendatchuan  ='@Tendatchuan') ";
        public static string TBLDM_LOAITRUONGCHUAN_INSERTPRC = "insert into TblDm_Loaitruongchuan(Tendatchuan) values(@Tendatchuan)";
        public static string TBLDM_LOAITRUONGCHUAN_SELECTALL_PRC = "select * from TblDm_Loaitruongchuan ORDER BY Tendatchuan";

        public static string TBLDM_NAMHOC_FINDNAMESAMEPRC = "select *  from TblDm_Namhoc where Tennamhoc='@Tennamhoc' ";

        public static string TBLDM_NHANTHUC_DEL = "delete FROM TblDm_Nhanthuc WHERE (Id =@Id) ";
        public static string TBLDM_NHANTHUC_EDITPRC = "	update TblDm_Nhanthuc set Tenmuc = '@Tenmuc' where Id =@Id";
        public static string TBLDM_NHANTHUC_FINDNAMESAMEPRC = "	" + " 	select * from TblDm_Nhanthuc where  (Tenmuc ='@VarTen'  ) ";
        public static string TBLDM_NHANTHUC_INSERTPRC = "insert into TblDm_Nhanthuc(Tenmuc) values( '@Tenmuc')";
        public static string TBLDM_NHANTHUC_SELECTALL_PRC = "select * from TblDm_Nhanthuc ORDER BY Tenmuc";
        //************************************************
        public static string TBLDM_PHIEUBENGOAN_SELECTALL_PRC = "select * from TblPhieuBeNgoan";
        public static string TBLDM_PHIEUBENGOAN_SELECTUAN_PRC = "select Tuan1, Tuan2, Tuan3, Tuan4 from TblPhieuBeNgoan";

        //*************************************************
        public static string TBLDM_NHOMTHUCPHAM_THUCAN_DEL = "delete FROM TblDm_Nhomthucpham_thucan WHERE Id = ?";
        public static string TBLDM_NHOMTHUCPHAM_THUCAN_EDITPRC = "UPDATE TblDm_Nhomthucpham_thucan SET Tennhom = @Tennhom WHERE Id = @Id";
        public static string TBLDM_NHOMTHUCPHAM_THUCAN_FINDNAMESAMEPRC = "select * from TblDm_Nhomthucpham_Thucan where Tennhom = ? ";
        public static string TBLDM_NHOMTHUCPHAM_THUCAN_INSERTPRC = "INSERT INTO TblDm_Nhomthucpham_thucan (Tennhom) VALUES (?)";
        public static string TBLDM_NHOMTHUCPHAM_THUCAN_SELECTALL_PRC = "SELECT * FROM TblDm_Nhomthucpham_thucan ORDER BY Tennhom DESC";

        public static string TBLDM_PHANLOAICANBO_DEL = " delete from TblDm_Phanloaicanbo WHERE Id = @Id ";
        public static string TblDm_Phanloaicanbo_FindNameSamePrc = "select * from TblDm_Phanloaicanbo where Phanloaicanbo = @VarTen";

        public static string TBLDM_PHANLOAILOP_FINDNAMESAMEPRC = "select * from TblDm_Phanloailop where Tenloailop = ?";

        public static string TBLDM_QUANHE_DEL = "delete FROM TblDm_Quanhe WHERE Id = ?";
        public static string TBLDM_QUANHE_EDITPRC = "update TblDm_Quanhe set Tenquanhe = '@Tenquanhe' where Id =@Id";
        public static string TBLDM_QUANHE_FINDNAMESAMEPRC = "select * from TblDm_Quanhe where  Tenquanhe = '@VarName'";
        public static string TBLDM_QUANHE_INSERTPRC = "insert into TblDm_Quanhe(Tenquanhe) values('@Tenquanhe')";
        public static string TBLDM_QUANHE_SELECTALL_PRC = "	select Id, Tenquanhe from TblDm_Quanhe ORDER BY Tenquanhe ";

        public static string TBLDM_QUOCTICH_FINDNAMESAMEPRC = "select * from TblDm_Quoctich where Tenquoctich = ? ";

        public static string TblDm_TblThamsodauvao_Prc = "select * from TblThamsodauvao";
        public static string TBLDM_THANSODAUVAO_VALUE2_EDITPRC = "update TblThamsodauvao set Baoanchitiet = @Baoanchitiet,Chitietdiemtruong= @Chitietdiemtruong where(Id = ?)";
        public static string TBLDM_THANSODAUVAO_VALUENOT2_EDITPRC = "update TblThamsodauvao "
 + "  SET  Nhanvienhosonam = ? "
 + "       ,Nhanvienhosogoc = ? "
 + "       ,Thutheothang = ? "
 + "       ,Thutheonam = ? "
 + "       ,Thutunguyen = ? "
 + "       ,Thucphamngay = ? "
 + "       ,NX_Thucpham = ? "
 + "       ,Baoan = ? "
 + "       ,Muaphieuan = ?, "
 + " Dulieunamhientai = ?, "
 + " Thucdonmonan =? "
 + "   where(Id = ?) ";
        public static string TBLDM_THUDAUNAM_FINDNAMESAMEPRC = "select * from TblDm_Thudaunam where (Tenmucthu = '@Tenmucthu' ) ";

        public static string TBLDM_THUKHONGBATBUOC_EDITPRC = "update TblDm_Thukhongbatbuoc set Ten = ? where(Id = ?)";
        public static string TBLDM_THUKHONGBATBUOC_FINDNAMESAMEPRC = "select * from TblDm_Thukhongbatbuoc where (Ten like '%?%' ) ";
        public static string TBLDM_THUKHONGBATBUOC_INSERTPRC = "insert into TblDm_Thukhongbatbuoc(Ten) values(?)";
        public static string TBLDM_THUKHONGBATBUOC_SELECTALL_PRC = "select Id, Ten from TblDm_Thukhongbatbuoc ORDER BY Ten ";

        public static string TBLDM_THUTHEOTHANG_DEL = "delete FROM TblDm_Thutheothang WHERE (Id = ?) ";
        public static string TBLDM_THUTHEOTHANG_EDITPRC = "update TblDm_Thutheothang set Tenmucthu= ?, Phi_Nhatre =?, Phi_Maugiao = ?, Phi_Nhombot =?, Phi_Nhomchao=?, Canam =? where Id= ? and ThanghocId =? ";
        public static string TBLDM_THUTHEOTHANG_FINDNAMESAMEPRC = "select * from TblDm_Thutheothang where (Tenmucthu like '%?%' and ThanghocId =? ) ";
        public static string TBLDM_THUTHEOTHANG_INSERTPRC = "insert into TblDm_Thutheothang(Tenmucthu,Phi_Nhombot, Phi_Nhomchao, Phi_Nhatre, Phi_Maugiao,ThanghocId,Canam) values('@Tenmucthu',@Phi_Nhombot, @Phi_Nhomchao, @Phi_Nhatre, @Phi_Maugiao,@ThanghocId,@Canam)";
        public static string TBLDM_THUTHEOTHANG_SELECTALLBYNAM_PRC = "select * from TblDm_Thutheothang where (ThanghocId = @Id ) ORDER BY Tenmucthu ";

        public static string TBLDM_THUVIENMONAN_FINDNAMESAMEPRC = "SELECT * FROM TblDm_Thuvienmonan WHERE Tenmonan like '%@VarTen%' and LoaimonId =@LoaimonId and DotuoiId =@DotuoiId ";

        public static string TBLDM_TINH_DEL = "delete FROM TblDm_Tinh WHERE Id = @Id ";
        public static string TBLDM_TINH_EDITPRC = "update TblDm_Tinh set Tentinh = '@Ten' where Id = @Id ";
        public static string TBLDM_TINH_FINDNAMESAMEPRC = "select *  from TblDm_Tinh where (Tentinh ='@Ten' ) ";
        public static string TBLDM_TINH_INSERTPRC = "insert into TblDm_Tinh(Tentinh) values('@Ten') ";
        public static string TBLDM_TINH_SELECTALL_PRC = "select Id, Tentinh from TblDm_Tinh ORDER BY Tentinh ";

        public static string TBLDM_TO_EDITPRC = "UPDATE TblDm_To SET TruongId = @TruongId, Tento = \"@Tento\" WHERE Id =@Id";
        public static string TBLDM_TO_FINDNAMESAMEPRC = "select * from TblDm_To where Tento = \"@VarTen\" ";
        public static string TBLDM_TO_INSERTPRC = "INSERT INTO TblDm_To(TruongId, Tento) VALUES (@TruongId, \"@Tento\" ) ";
        public static string TBLDM_TO_SELECTALL_PRC = "SELECT * FROM TblDm_To ORDER BY Tento ";

        public static string TBLDM_TONGIAO_DEL = "delete from TblDm_Tongiao where Id = ? ";
        public static string TBLDM_TONGIAO_EDITPRC = "update TblDm_Tongiao set Tentongiao = '@Tentongiao' where Id =@Id";
        public static string TBLDM_TONGIAO_FINDNAMESAMEPRC = "select * from TblDm_Tongiao where Tentongiao= ? ";
        public static string TBLDM_TONGIAO_INSERTPRC = "insert into TblDm_Tongiao(Tentongiao) values(?)";
        public static string TBLDM_TONGIAO_SELECTALL_PRC = "select Id, Tentongiao from TblDm_Tongiao ORDER BY Tentongiao ";

        //TblUutien
        public static string TBLDM_UUTIEN_INSERTPRC = "insert into TblDm_Uutien(Tenuutien) values('@Tenuutien')";
        public static string TBLDM_UUTIEN_EDITPRC = "update TblDm_Uutien set Tenuutien = '@Tenuutien' where(Id =@Id)";
        public static string TBLDM_UUTIEN_DEL = "delete from TblDm_Uutien where (Id = ?)";
        public static string TBLDM_UUTIEN_FINDNAMESAMEPRC = "select * from TblDm_Uutien where (Tenuutien ='@Tenuutien')";
        public static string SP_UUTIEN_SELECTALL = "SELECT Id, Tenuutien FROM TblDm_Uutien ORDER BY Tenuutien";

        public static string TBLDM_XA_DEL = "delete FROM TblDm_Xa WHERE Id = @Id ";
        public static string TBLDM_XA_EDITPRC = "update TblDm_Xa set HuyenId = @HuyenId, Tenxa = '@Tenxa' where Id = @Id ";
        public static string TBLDM_XA_FINDNAMESAMEPRC = "select * from TblDm_Xa  where Tenxa = '@Tenxa'  and HuyenId = @HuyenId ";
        public static string TBLDM_XA_INSERTPRC = "insert into TblDm_Xa(HuyenId, Tenxa) values(@HuyenId, '@Tenxa') ";
        public static string TBLDM_XA_SELECTALLBYHUYENID_PRC = "select Id, Tenxa, HuyenId from TblDm_Xa where HuyenId = @HuyenId ORDER BY Tenxa ";

        public static string TBLDM_XEPLOAI_DEL = "delete from TblDm_Xeploai WHERE Id = @Id ";
        public static string TBLDM_XEPLOAI_EDITPRC = "update TblDm_Xeploai set Tenxeploai = '@Ten' where Id = @Id";
        public static string TBLDM_XEPLOAI_FINDNAMESAMEPRC = "select * from TblDm_Xeploai where Tenxeploai = '@VarTen'";
        public static string TBLDM_XEPLOAI_INSERTPRC = "insert into TblDm_Xeploai(Tenxeploai ) values('@Ten')";
        public static string TBLDM_XEPLOAI_SELECTALL_PRC = "select * from TblDm_Xeploai";

        public static string TBLLOPBYDOTUOIID = "SELECT NamhocId, DotuoiId, PhanloailopId, PhonghocId, Tenlop, Id FROM TblLop WHERE DotuoiId = ? ";
        public static string TBLMUCGIAMUUTIENNAMBYTHUDAUNAMID = "SELECT Id, UutienId, ThudaunamId, Dinhmucgiam FROM TblMucgiamuutiennam WHERE ThudaunamId = ? ";
        public static string TBLNHANVIEN_FINDSAMECMNDPRC = "select * from TblNhanvien  where CMND = ? ";
        public static string TBLNHANVIEN_GIADINH_FINDNAMESAMEPRC = "select * from TblNhanvien_giadinh where  Hoten like '%?%' ";
        public static string TBLNHANVIENBYDATCHUANID = "SELECT Id, Hotendem, Ten, Namsinh, Gioitinh, CMND, Noicap, Ngaycap, Tpbanthan, Tpgiadinh, Quequan, Noiohientai, DantocId, DatchuanId, TongiaoId, Email, Dienthoai, QuoctichId, UutienId, Trangthai FROM TblNhanvien WHERE DatchuanId = ?";
        public static string TBLTHUCDON_MONANBYBUAANTRONGNGAYID = "SELECT Ngay, BuaantrongngayId, KhoilopId FROM TblThucdon_monan WHERE BuaantrongngayId = ? ";
        public static string TBLTHUCPHAM_THUCAN_FINDNAMESAMEPRC = "	SELECT TblThucpham_thucan.Id, TblThucpham_thucan.Tenthucan, TblDm_Donvitinh.Tendonvitinh"
 + " FROM         TblDm_Donvitinh INNER JOIN "
 + "                       TblThucpham_thucan ON TblDm_Donvitinh.Id = TblThucpham_thucan.DonvitinhId "
 + " WHERE     (TblThucpham_thucan.NhomthucanId = @NhomthucanId) AND (TblThucpham_thucan.Tenthucan LIKE '%' + ? + '%') ";
        public static string TBLTHUCPHAM_THUCANBYNHOMTHUCANID = "SELECT NhomthucanId, Id, Tenthucan, Tylequydoi FROM TblThucpham_thucan WHERE NhomthucanId = ? ";
        public static string TBLTREKIEMTRANHANTHUCBYNHANTHUCID = "SELECT NamtrehocId, NhanthucId, ThanghocId, Datchuan, Ngaykiemtra FROM TblTrekiemtranhanthuc WHERE NhanthucId = ? ";
        public static string TBLTREMACBENHBYBENHLYID = "SELECT NamtrehocId, BenhlyId, Noidieutri, Ngayxuat, Ngaynhap, Ghichu, Id FROM TblTremacbenh WHERE BenhlyId = ? ";
        public static string TBLTREPHAITHUNAMBYTHUDAUNAMID = "SELECT ThudaunamId, Id, NamtrehocId, Mucthu, Duocgiam, Phainop, Danop, Conlai, Nopthem FROM TblTrephaithunam WHERE ThudaunamId = ? ";
        public static string THOMND_PRCTBLDM_NHAPXUATHANGHOABYID = "SELECT TblXuathanghoagiatrungbinh.Dongia, TblHoadonnhapxuat.NgayNX"
 + " FROM         TblXuathanghoagiatrungbinh INNER JOIN "
 + "                       TblHoadonnhapxuat ON TblXuathanghoagiatrungbinh.HoadonnhapxuatId = TblHoadonnhapxuat.Id "
 + " WHERE     (TblHoadonnhapxuat.NgayNX <= @NgayNX) AND (TblHoadonnhapxuat.Trangthai = @TrangthaiNX) AND  "
 + "                       (TblXuathanghoagiatrungbinh.Thucpham_ThucanId = ?) "
 + " ORDER BY TblHoadonnhapxuat.NgayNX DESC ";
        public static string SP_TblDmSuckhoedotuoi_SelectByVar = "SELECT TblGoc.Id, TblGoc.KenhId, TblTrunggian.Thangtuoi, IIF(TblGoc.Giatri1=Null,0,TblGoc.Giatri1)  AS Giatri1,IIF(TblGoc.Giatri2=Null,0,TblGoc.Giatri2)   AS Giatri2,  "
 + "              '@Gioitinh' AS Gioitinh, '@Chiso' AS Chiso, TblTrunggian.Tenthang "
 + " FROM         (SELECT     Id, KenhId, Thangtuoi, Giatri1, Giatri2, Gioitinh, Chiso "
 + "               FROM          TblDm_Suckhoethangtuoi "
 + "               WHERE      (KenhId = @KenhId) AND (Gioitinh LIKE  '%@Gioitinh%') AND (Chiso LIKE '%@Chiso%')) AS TblGoc RIGHT OUTER JOIN "
 + "                  (SELECT     Thangtuoi, Tenthang "
 + "                    FROM          TblTrunggian AS TblTrunggian_1 "
 + "                    WHERE      (Thangtuoi > @Thangtuoi1) AND (Thangtuoi < @Thangtuoi2)) AS TblTrunggian ON TblGoc.Thangtuoi = TblTrunggian.Thangtuoi ORDER BY TblTrunggian.Thangtuoi";
        //public static string TblDm_TblThamsodauvao_Prc = "select * from TblThamsodauvao ";

        public static string SP_ThucphambyThucpham_thucanId = "SELECT     ISNULL(DV.Thucpham_ThucanId, TV.Thucpham_ThucanId) AS Thucpham_ThucanId, ISNULL(DV.ListTenthucan, TV.ListTenthucan) AS ListTenthucan,  "
 + "                      ISNULL(ISNULL(DV.Calo, TV.Calo), 0) AS Calo, ISNULL(DV.Tphh_Protid, 0) AS DV_Protid, ISNULL(DV.Tphh_Lipid, 0) AS DV_Lipid, "
 + "                      ISNULL(DV.Tphh_GlucId, TV.Tphh_GlucId) AS GlucId, ISNULL(DV.ListTendonvitinh, TV.ListTendonvitinh) AS ListTendonvitinh,  "
 + "                      ISNULL(ISNULL(DV.Tylequydoi, TV.Tylequydoi), 0) AS Tylequydoi, ISNULL(TV.Tphh_Protid, 0) AS TV_Protid, ISNULL(TV.Tphh_Lipid, 0) AS TV_Lipid,  "
 + "                      ISNULL(ISNULL(TV.Tylethai, DV.Tylethai), 0) AS Tylethai "
 + " FROM         (SELECT     TblThucpham_thucan_1.Id AS Thucpham_ThucanId, TblThucpham_thucan_1.Tenthucan AS ListTenthucan, TblThucpham_thucan_1.Calo,  "
 + "                      TblThanhphanhoahoc_1.Tphh_Protid, TblThanhphanhoahoc_1.Tphh_Lipid, TblThanhphanhoahoc_1.Tphh_GlucId,  "
 + "                      TblDm_Donvitinh_1.Tendonvitinh AS ListTendonvitinh, TblThucpham_thucan_1.Tylequydoi, TblThucpham_thucan_1.Tylethai,  "
 + "                      TblThucpham_thucan_1.Nguondongvat "
 + " FROM        TblThucpham_thucan AS TblThucpham_thucan_1 INNER JOIN "
 + "                      TblDm_Donvitinh AS TblDm_Donvitinh_1 ON TblThucpham_thucan_1.DonvitinhId = TblDm_Donvitinh_1.Id INNER JOIN "
 + "                      TblThanhphanhoahoc AS TblThanhphanhoahoc_1 ON TblThucpham_thucan_1.Id = TblThanhphanhoahoc_1.IdThucpham_thucan "
 + " WHERE     (TblThucpham_thucan_1.Id = ?) AND (TblThucpham_thucan_1.Nguondongvat = 1)) AS DV FULL OUTER JOIN "
 + "                          (SELECT     TblThucpham_thucan_1.Id AS Thucpham_ThucanId, TblThucpham_thucan_1.Tenthucan AS ListTenthucan, TblThucpham_thucan_1.Calo,  "
 + "                      TblThanhphanhoahoc_1.Tphh_Protid, TblThanhphanhoahoc_1.Tphh_Lipid, TblThanhphanhoahoc_1.Tphh_GlucId,  "
 + "                      TblDm_Donvitinh_1.Tendonvitinh AS ListTendonvitinh, TblThucpham_thucan_1.Tylequydoi, TblThucpham_thucan_1.Tylethai,  "
 + "                      TblThucpham_thucan_1.Nguondongvat "
 + " FROM         TblThucpham_thucan AS TblThucpham_thucan_1 INNER JOIN "
 + "                     TblDm_Donvitinh AS TblDm_Donvitinh_1 ON TblThucpham_thucan_1.DonvitinhId = TblDm_Donvitinh_1.Id INNER JOIN "
 + "                      TblThanhphanhoahoc AS TblThanhphanhoahoc_1 ON TblThucpham_thucan_1.Id = TblThanhphanhoahoc_1.IdThucpham_thucan "
 + "WHERE     (TblThucpham_thucan_1.Id = ?) AND (TblThucpham_thucan_1.Nguondongvat = 0)) AS TV ON DV.Thucpham_ThucanId = TV.Thucpham_ThucanId";
        public static string SP_Thucphamtheobua_DeleteByNamhocId = "delete "
 + "FROM         Thucphamtheobua "
 + "WHERE     (NamhocId = ?) ";

        //public static string TblDm_Phanloaicanbo_FindNameSamePrc = "select  * from TblDm_Phanloaicanbo where (Phanloaicanbo = ? )";
        public static string sproc_TblLop_GetAll = "SELECT TblLop.Id,TblLop.Tenlop,TblLop.PhonghocId,TblLop.NamhocId,TblLop.DotuoiId,TblLop.PhanloailopId,TblLop.Bantru FROM TblLop where NamhocId = ? ORDER BY TblLop.Tenlop";

        public static string sproc_TblTrephaithunam_GetByNamtrehocId = "select ROW_NUMBER() OVER (ORDER BY tenthuonggoi) AS STT, NamtrehocId,LophocId,Id, ThudaunamId, Hovaten, Tenthuonggoi, "
        + "	isnull(Mucthu, 0) as Mucthu, isnull(Duocgiam, (SELECT Dinhmucgiam "
        + "													FROM vwDinhmucgiamNam "
        + "													WHERE vwDinhmucgiamNam.ThudaunamId = ' + convert(nvarchar(10), @ThudaunamId) + '  and vwDinhmucgiamNam.NamtrehocId = tbl.NamtrehocId))as Duocgiam,  "
        + "	isnull(Phainop, 0)as Phainop, Danop, isnull(Conlai, 0)as Conlai, isnull(Nopthem, 0)as Nopthem "
        + " from "
        + "	(SELECT     tbltrenamhoc.NamtrehocId, tbltrenamhoc.LophocId, tbltrenamhoc.Hovaten, tbltrenamhoc.Tenthuonggoi, tbltrenamhoc.TreId, tbltrenamhoc.NamhocId,  "
        + "          tbltrenamhoc.Tinhtrang, tbltrenamhoc.thudaunamid, TblTrephaithunam.Id, (SELECT     Mucthu "
        + "                FROM          vwMucthuNam "
        + "                WHERE      (NamtrehocId = tbltrenamhoc.NamtrehocId) AND (ThutheonamID = ' + convert(nvarchar(10), @ThudaunamId) + ')) Mucthu, TblTrephaithunam.Duocgiam,  "
        + "              TblTrephaithunam.Phainop, TblTrephaithunam.Danop, TblTrephaithunam.Conlai, TblTrephaithunam.Nopthem "
        + " FROM         (SELECT     NamtrehocId, LophocId, Hovaten, Tenthuonggoi, TreId, NamhocId, Tinhtrang, ' + convert(nvarchar(10), @ThudaunamId) + ' AS thudaunamid "
        + "                       FROM          Vw_Tre_namtrehoc) AS tbltrenamhoc LEFT OUTER JOIN "
        + "                      TblTrephaithunam ON tbltrenamhoc.NamtrehocId = TblTrephaithunam.NamtrehocId AND  "
        + "                      tbltrenamhoc.thudaunamid = TblTrephaithunam.ThudaunamId "
        + "				WHERE  tbltrenamhoc.NamhocId = ' + convert(nvarchar(10), @NamhocId) + ' AND (tbltrenamhoc.NamtrehocId ='+ convert(nvarchar(10), @NamtrehocId)+ ') ' "
        + " set @SQL = @SQL + ') as tbl where  tbl.ThudaunamId = ' + convert(nvarchar(10), @ThudaunamId) + ' or tbl.ThudaunamId is null'";
    }
}
